1
- # OpenShot Video Editor is a program that creates, modifies, and edits video files.
1
+ # OpenShot Video Editor is a program that creates, modifies, and edits video files.
2
2
# Copyright (C) 2009 Jonathan Thomas
3
3
#
4
- # This file is part of OpenShot Video Editor (http://launchpad.net/openshot/).
4
+ # This file is part of OpenShot Video Editor (http://launchpad.net/openshot/).
5
5
#
6
- # OpenShot Video Editor is free software: you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation, either version 3 of the License, or
9
- # (at your option) any later version.
6
+ # OpenShot Video Editor is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
10
#
11
- # OpenShot Video Editor is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
11
+ # OpenShot Video Editor is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
15
#
16
- # You should have received a copy of the GNU General Public License
17
- # along with OpenShot Video Editor. If not, see <http://www.gnu.org/licenses/>.
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with OpenShot Video Editor. If not, see <http://www.gnu.org/licenses/>.
18
18
19
19
20
20
# Import Blender's python API. This only works when the script is being
21
21
# run from the context of Blender. Blender contains it's own version of Python
22
22
# with this library pre-installed.
23
23
import bpy
24
24
25
- # Load a font
25
+
26
26
def load_font (font_path ):
27
- """ Load a new TTF font into Blender, and return the font object """
28
- # get the original list of fonts (before we add a new one)
29
- original_fonts = bpy .data .fonts .keys ()
30
-
31
- # load new font
32
- bpy .ops .font .open (filepath = font_path )
33
-
34
- # get the new list of fonts (after we added a new one)
35
- for font_name in bpy .data .fonts .keys ():
36
- if font_name not in original_fonts :
37
- return bpy .data .fonts [font_name ]
38
-
39
- # no new font was added
40
- return None
27
+ """ Load a new TTF font into Blender, and return the font object """
28
+ # get the original list of fonts (before we add a new one)
29
+ original_fonts = bpy .data .fonts .keys ()
30
+
31
+ # load new font
32
+ bpy .ops .font .open (filepath = font_path )
33
+
34
+ # get the new list of fonts (after we added a new one)
35
+ for font_name in bpy .data .fonts .keys ():
36
+ if font_name not in original_fonts :
37
+ return bpy .data .fonts [font_name ]
38
+
39
+ # no new font was added
40
+ return None
41
41
42
42
# Debug Info:
43
43
# ./blender -b test.blend -P demo.py
44
44
# -b = background mode
45
45
# -P = run a Python script within the context of the project file
46
46
47
+
47
48
# Init all of the variables needed by this script. Because Blender executes
48
49
# this script, OpenShot will inject a dictionary of the required parameters
49
50
# before this script is executed.
50
- params = {
51
- 'title' : 'Oh Yeah! OpenShot!' ,
52
- 'extrude' : 0.1 ,
53
- 'bevel_depth' : 0.02 ,
54
- 'spacemode' : 'CENTER' ,
55
- 'text_size' : 1.5 ,
56
- 'width' : 1.0 ,
57
- 'fontname' : 'Bfont' ,
58
-
59
- 'color' : [0.8 ,0.8 ,0.8 ],
60
- 'alpha' : 1.0 ,
61
-
62
- 'output_path' : '/tmp/' ,
63
- 'fps' : 24 ,
64
- 'quality' : 90 ,
65
- 'file_format' : 'PNG' ,
66
- 'color_mode' : 'RGBA' ,
67
- 'horizon_color' : [0.57 , 0.57 , 0.57 ],
68
- 'resolution_x' : 1920 ,
69
- 'resolution_y' : 1080 ,
70
- 'resolution_percentage' : 100 ,
71
- 'start_frame' : 20 ,
72
- 'end_frame' : 25 ,
73
- 'animation' : True ,
74
- }
75
-
76
- #INJECT_PARAMS_HERE
51
+ params = {
52
+ 'title' : 'Oh Yeah! OpenShot!' ,
53
+ 'extrude' : 0.1 ,
54
+ 'bevel_depth' : 0.02 ,
55
+ 'spacemode' : 'CENTER' ,
56
+ 'text_size' : 1.5 ,
57
+ 'width' : 1.0 ,
58
+ 'fontname' : 'Bfont' ,
59
+
60
+ 'color' : [0.8 , 0.8 , 0.8 ],
61
+ 'alpha' : 1.0 ,
62
+
63
+ 'output_path' : '/tmp/' ,
64
+ 'fps' : 24 ,
65
+ 'quality' : 90 ,
66
+ 'file_format' : 'PNG' ,
67
+ 'color_mode' : 'RGBA' ,
68
+ 'horizon_color' : [0.57 , 0.57 , 0.57 ],
69
+ 'resolution_x' : 1920 ,
70
+ 'resolution_y' : 1080 ,
71
+ 'resolution_percentage' : 100 ,
72
+ 'start_frame' : 20 ,
73
+ 'end_frame' : 25 ,
74
+ 'animation' : True ,
75
+ }
76
+
77
+ # INJECT_PARAMS_HERE
77
78
78
79
# The remainder of this script will modify the current Blender .blend project
79
80
# file, and adjust the settings. The .blend file is specified in the XML file
80
81
# that defines this template in OpenShot.
81
- #----------------------------------------------------------------------------
82
+ # ----------------------------------------------------------------------------
82
83
83
84
# Modify Text / Curve settings
84
85
#print (bpy.data.curves.keys())
@@ -93,12 +94,12 @@ def load_font(font_path):
93
94
# Get font object
94
95
font = None
95
96
if params ["fontname" ] != "Bfont" :
96
- # Add font so it's available to Blender
97
- font = load_font (params ["fontname" ])
97
+ # Add font so it's available to Blender
98
+ font = load_font (params ["fontname" ])
98
99
else :
99
- # Get default font
100
- font = bpy .data .fonts ["Bfont" ]
101
-
100
+ # Get default font
101
+ font = bpy .data .fonts ["Bfont" ]
102
+
102
103
text_object .font = font
103
104
104
105
text_object = bpy .data .curves ["Subtitle" ]
@@ -134,15 +135,14 @@ def load_font(font_path):
134
135
bpy .context .scene .frame_end = params ["end_frame" ]
135
136
136
137
# Animation Speed (use Blender's time remapping to slow or speed up animation)
137
- animation_speed = int (params ["animation_speed" ]) # time remapping multiplier
138
- new_length = int (params ["end_frame" ]) * animation_speed # new length (in frames)
138
+ animation_speed = int (params ["animation_speed" ]) # time remapping multiplier
139
+ new_length = int (params ["end_frame" ]) * animation_speed # new length (in frames)
139
140
bpy .context .scene .frame_end = new_length
140
141
bpy .context .scene .render .frame_map_old = 1
141
142
bpy .context .scene .render .frame_map_new = animation_speed
142
143
if params ["start_frame" ] == params ["end_frame" ]:
143
- bpy .context .scene .frame_start = params ["end_frame" ]
144
- bpy .context .scene .frame_end = params ["end_frame" ]
144
+ bpy .context .scene .frame_start = params ["end_frame" ]
145
+ bpy .context .scene .frame_end = params ["end_frame" ]
145
146
146
147
# Render the current animation to the params["output_path"] folder
147
148
bpy .ops .render .render (animation = params ["animation" ])
148
-
0 commit comments