fix render single file
parent
f57c4f8133
commit
a449f146f1
|
@ -85,6 +85,8 @@ def get_bl_cmd(blender=None, background=False, focus=True, blendfile=None, scrip
|
|||
|
||||
def background_render(output=None):
|
||||
#bpy.context.scene.render.filepath = '{output}'
|
||||
|
||||
output = os.path.abspath(bpy.path.abspath(output))
|
||||
script_code = dedent(f"""
|
||||
import bpy
|
||||
bpy.context.scene.render.filepath = '{str(output)}'
|
||||
|
@ -93,7 +95,7 @@ def background_render(output=None):
|
|||
""")
|
||||
|
||||
tmp_blend = Path(bpy.app.tempdir) / Path(bpy.data.filepath).name
|
||||
bpy.ops.wm.save_as_mainfile(filepath=str(tmp_blend))
|
||||
bpy.ops.wm.save_as_mainfile(filepath=str(tmp_blend), copy=True)
|
||||
|
||||
script_path = Path(bpy.app.tempdir) / 'render_blender_background.py'
|
||||
script_path.write_text(script_code)
|
||||
|
|
|
@ -9,7 +9,7 @@ from bpy.types import Operator
|
|||
from bpy.props import BoolProperty
|
||||
|
||||
from vse_toolbox.sequencer_utils import (get_strips, render_strip, render_sound)
|
||||
from vse_toolbox.bl_utils import (get_scene_settings, background_render)
|
||||
from vse_toolbox.bl_utils import (get_scene_settings, background_render, render_scene)
|
||||
from vse_toolbox.file_utils import install_module
|
||||
|
||||
|
||||
|
@ -92,7 +92,8 @@ class VSETB_OT_render(Operator):
|
|||
start_time = time.perf_counter()
|
||||
if project.render_video:
|
||||
video_path = project.render_video_template.format(**format_data)
|
||||
background_render(output=video_path)
|
||||
render_scene(video_path)
|
||||
#background_render(output=video_path)
|
||||
|
||||
if project.render_audio:
|
||||
audio_path = project.render_audio_template.format(**format_data)
|
||||
|
|
|
@ -255,6 +255,20 @@ def render_sound(strip, output):
|
|||
scn.frame_end = scene_end
|
||||
scn.frame_current = scene_current
|
||||
|
||||
def render_scene(output):
|
||||
output = os.path.abspath(bpy.path.abspath(output))
|
||||
|
||||
scn = bpy.context.scene
|
||||
render_path = scn.render.filepath
|
||||
|
||||
scn.render.filepath = output
|
||||
|
||||
print(f'Render Strip to {scn.render.filepath}')
|
||||
Path(output).parent.mkdir(exist_ok=True, parents=True)
|
||||
bpy.ops.render.opengl(animation=True, sequencer=True)
|
||||
|
||||
scn.render.filepath = render_path
|
||||
|
||||
def render_strip(strip, output):
|
||||
output = os.path.abspath(bpy.path.abspath(output))
|
||||
|
||||
|
@ -475,8 +489,6 @@ def update_text_strips(scene):
|
|||
|
||||
shot_strip = get_strip_at('Shots', frame=scene.frame_current)
|
||||
if shot_strip:
|
||||
|
||||
|
||||
format_data.update({
|
||||
'project_name': project.name,
|
||||
'episode_name': episode.name if episode else '',
|
||||
|
|
Loading…
Reference in New Issue