From a449f146f11c054b345bc07041e1d570b70419d7 Mon Sep 17 00:00:00 2001 From: ChristopheSeux Date: Mon, 9 Oct 2023 18:30:06 +0200 Subject: [PATCH] fix render single file --- bl_utils.py | 4 +++- operators/exports.py | 5 +++-- sequencer_utils.py | 16 ++++++++++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/bl_utils.py b/bl_utils.py index 9262d8c..11bfdfa 100644 --- a/bl_utils.py +++ b/bl_utils.py @@ -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) diff --git a/operators/exports.py b/operators/exports.py index 21c75b7..1a36632 100644 --- a/operators/exports.py +++ b/operators/exports.py @@ -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) diff --git a/sequencer_utils.py b/sequencer_utils.py index b58aae3..c8cae24 100644 --- a/sequencer_utils.py +++ b/sequencer_utils.py @@ -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 '',