1
# OpenShot Video Editor is a program that creates, modifies, and edits video files.
2
# Copyright (C) 2009 Jonathan Thomas
4
# This file is part of OpenShot Video Editor (http://launchpad.net/openshot/).
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.
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.
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/>.
20
# Import Blender's python API. This only works when the script is being
21
# run from the context of Blender. Blender contains it's own version of Python
22
# with this library pre-installed.
26
# ./blender -b test.blend -P demo.py
27
# -b = background mode
28
# -P = run a Python script within the context of the project file
30
# Init all of the variables needed by this script. Because Blender executes
31
# this script, OpenShot will inject a dictionary of the required parameters
32
# before this script is executed.
34
'title' : 'Oh Yeah! OpenShot!',
37
'spacemode' : 'CENTRAL',
42
'color' : [0.8,0.8,0.8],
45
'line1_color' : [0.8,0.8,0.8],
46
'line2_color' : [0.8,0.8,0.8],
47
'line3_color' : [0.8,0.8,0.8],
48
'line4_color' : [0.8,0.8,0.8],
50
'output_path' : '/tmp/',
53
'file_format' : 'PNG',
54
'color_mode' : 'RGBA',
55
'horizon_color' : [0.57, 0.57, 0.57],
56
'resolution_x' : 1920,
57
'resolution_y' : 1080,
58
'resolution_percentage' : 100,
66
# The remainder of this script will modify the current Blender .blend project
67
# file, and adjust the settings. The .blend file is specified in the XML file
68
# that defines this template in OpenShot.
69
#----------------------------------------------------------------------------
71
# Modify Text / Curve settings
72
#print (bpy.data.curves.keys())
73
text_object = bpy.data.curves["Text.001"]
74
text_object.extrude = params["extrude"]
75
text_object.bevel_depth = params["bevel_depth"]
76
text_object.body = params["title"]
77
text_object.align = params["spacemode"]
78
text_object.size = params["text_size"]
79
text_object.space_character = params["width"]
81
# Get vector font object (these are defined in the .blend file)
82
# Only fonts added to your .blend file can be used here
83
font = bpy.data.fonts[params["fontname"]]
84
text_object.font = font
86
# Change the material settings (color, alpha, etc...)
87
material_object = bpy.data.materials["Material.title"]
88
material_object.diffuse_color = params["diffuse_color"]
89
material_object.specular_color = params["specular_color"]
90
material_object.specular_intensity = params["specular_intensity"]
91
material_object.alpha = params["alpha"]
94
material_object = bpy.data.materials["Material.line1"]
95
material_object.diffuse_color = params["line1_color"]
96
material_object = bpy.data.materials["Material.line2"]
97
material_object.diffuse_color = params["line2_color"]
98
material_object = bpy.data.materials["Material.line3"]
99
material_object.diffuse_color = params["line3_color"]
100
material_object = bpy.data.materials["Material.line4"]
101
material_object.diffuse_color = params["line4_color"]
104
# Set the render options. It is important that these are set
105
# to the same values as the current OpenShot project. These
106
# params are automatically set by OpenShot
107
bpy.context.scene.render.filepath = params["output_path"]
108
bpy.context.scene.render.fps = params["fps"]
109
#bpy.context.scene.render.quality = params["quality"]
110
bpy.context.scene.render.file_format = params["file_format"]
111
bpy.context.scene.render.color_mode = params["color_mode"]
112
#bpy.data.worlds[0].horizon_color = params["horizon_color"]
113
bpy.context.scene.render.resolution_x = params["resolution_x"]
114
bpy.context.scene.render.resolution_y = params["resolution_y"]
115
bpy.context.scene.render.resolution_percentage = params["resolution_percentage"]
116
bpy.context.scene.frame_start = params["start_frame"]
117
bpy.context.scene.frame_end = params["end_frame"]
119
# Render the current animation to the params["output_path"] folder
120
bpy.ops.render.render(animation=params["animation"])