Export sound separatly
parent
4513fc7036
commit
5d353b89b8
|
@ -8,7 +8,7 @@ import bpy
|
|||
from bpy.types import Operator
|
||||
from bpy.props import BoolProperty
|
||||
|
||||
from vse_toolbox.sequencer_utils import (get_strips, render_strip)
|
||||
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.file_utils import install_module
|
||||
|
||||
|
@ -38,20 +38,44 @@ class VSETB_OT_render(Operator):
|
|||
settings = get_scene_settings()
|
||||
|
||||
layout = self.layout
|
||||
|
||||
col = layout.column()
|
||||
col.label(text='Single File', icon='FILE_IMAGE')
|
||||
#col.use_property_split = True
|
||||
#col.use_property_decorate = False
|
||||
|
||||
|
||||
col.prop(settings.active_project, "render_single_file")
|
||||
#col.prop(settings.active_project, "render_single_file")
|
||||
|
||||
row = col.row()
|
||||
row.enabled = settings.active_project.render_single_file
|
||||
row.prop(settings.active_project, "render_template")
|
||||
row.prop(settings.active_project, "render_video")
|
||||
row = col.row()
|
||||
row.enabled = settings.active_project.render_video
|
||||
row.prop(settings.active_project, "render_video_template")
|
||||
|
||||
row = col.row()
|
||||
row.prop(settings.active_project, "render_audio")
|
||||
row = col.row()
|
||||
row.enabled = settings.active_project.render_audio
|
||||
row.prop(settings.active_project, "render_audio_template")
|
||||
|
||||
layout.separator()
|
||||
col = layout.column()
|
||||
col.label(text='File per strip', icon='RENDERLAYERS')
|
||||
|
||||
|
||||
col.separator()
|
||||
col.prop(settings.active_project, "render_per_strip")
|
||||
col.prop(settings.active_project, "render_video_per_strip", text='Render Video')
|
||||
row = col.row()
|
||||
row.enabled = settings.active_project.render_per_strip
|
||||
row.prop(settings.active_project, "render_strip_template")
|
||||
row.enabled = settings.active_project.render_video_per_strip
|
||||
row.prop(settings.active_project, "render_video_strip_template", text='Video Template')
|
||||
|
||||
col.prop(settings.active_project, "render_audio_per_strip", text='Render Audio')
|
||||
row = col.row()
|
||||
row.enabled = settings.active_project.render_audio_per_strip
|
||||
row.prop(settings.active_project, "render_audio_strip_template", text='Audio Template')
|
||||
#row.prop(settings.active_project, "render_sound_format", expand=True)
|
||||
|
||||
|
||||
#col.prop(settings, 'channel', text='Channel')
|
||||
#col.prop(self, 'selected_only')
|
||||
|
@ -64,19 +88,26 @@ class VSETB_OT_render(Operator):
|
|||
format_data = {**settings.format_data, **project.format_data}
|
||||
|
||||
start_time = time.perf_counter()
|
||||
if project.render_single_file:
|
||||
render_path = project.render_template.format(**format_data)
|
||||
background_render(output=render_path)
|
||||
|
||||
if project.render_per_strip:
|
||||
for strip in get_strips(channel='Shots', selected_only=True):
|
||||
strip_settings = strip.vsetb_strip_settings
|
||||
strip_data = {**format_data, **strip_settings.format_data}
|
||||
strip_render_path = project.render_strip_template.format(**strip_data)
|
||||
if project.render_video:
|
||||
video_path = project.render_video_template.format(**format_data)
|
||||
background_render(output=video_path)
|
||||
|
||||
|
||||
if project.render_audio:
|
||||
audio_path = project.render_audio_template.format(**format_data)
|
||||
bpy.ops.sound.mixdown(filepath=audio_path)
|
||||
|
||||
for strip in get_strips(channel='Shots', selected_only=True):
|
||||
strip_settings = strip.vsetb_strip_settings
|
||||
strip_data = {**format_data, **strip_settings.format_data}
|
||||
|
||||
if project.render_video_per_strip:
|
||||
strip_render_path = project.render_video_strip_template.format(**strip_data)
|
||||
render_strip(strip, strip_render_path)
|
||||
|
||||
if project.render_audio_per_strip:
|
||||
audio_render_path = project.render_audio_strip_template.format(**strip_data)
|
||||
render_sound(strip, audio_render_path)
|
||||
|
||||
self.report({"INFO"}, f'Strips rendered in {time.perf_counter()-start_time} seconds')
|
||||
|
||||
return {"FINISHED"}
|
||||
|
|
|
@ -234,6 +234,27 @@ def render_strips(strips, template):
|
|||
scn.render.filepath = render_path
|
||||
'''
|
||||
|
||||
|
||||
def render_sound(strip, output):
|
||||
output = os.path.abspath(bpy.path.abspath(output))
|
||||
#ext = os.path.splitext(output)[1:]
|
||||
|
||||
scn = bpy.context.scene
|
||||
scene_start = scn.frame_start
|
||||
scene_end = scn.frame_end
|
||||
scene_current = scn.frame_current
|
||||
|
||||
scn.frame_start = strip.frame_final_start
|
||||
scn.frame_end = strip.frame_final_end - 1
|
||||
|
||||
print(f'Render Strip to {scn.render.filepath}')
|
||||
Path(output).parent.mkdir(exist_ok=True, parents=True)
|
||||
bpy.ops.sound.mixdown(filepath=output)#, container=ext.upper()
|
||||
|
||||
scn.frame_start = scene_start
|
||||
scn.frame_end = scene_end
|
||||
scn.frame_current = scene_current
|
||||
|
||||
def render_strip(strip, output):
|
||||
output = os.path.abspath(bpy.path.abspath(output))
|
||||
|
||||
|
@ -248,6 +269,7 @@ def render_strip(strip, output):
|
|||
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.frame_start = scene_start
|
||||
|
|
|
@ -246,15 +246,25 @@ class Project(PropertyGroup):
|
|||
shot_template : StringProperty(
|
||||
name="Shot Name", default="{sequence}_sh{index:04d}")
|
||||
|
||||
render_template : StringProperty(
|
||||
render_video_template : StringProperty(
|
||||
name="Movie Path", default="//render/{project_basename}.{ext}")
|
||||
|
||||
render_strip_template : StringProperty(
|
||||
render_audio_template : StringProperty(
|
||||
name="Audio Path", default="//render/{project_basename}.wav")
|
||||
|
||||
render_video_strip_template : StringProperty(
|
||||
name="Strip Path", default="//render/shots/{strip}.{ext}")
|
||||
|
||||
render_per_strip: BoolProperty(name="Per Strip", default=True)
|
||||
render_single_file: BoolProperty(name="Single File", default=False)
|
||||
render_audio_strip_template: StringProperty(
|
||||
name="Sound Path", default="//render/sounds/{strip}.wav")
|
||||
|
||||
render_video: BoolProperty(name="Render Video", default=False)
|
||||
render_audio: BoolProperty(name="Render Audio", default=False)
|
||||
|
||||
render_video_per_strip: BoolProperty(name="Render video per strip", default=True)
|
||||
render_audio_per_strip: BoolProperty(name="Render audio per strip", default=False)
|
||||
#render_sound_format: EnumProperty(items=[(e, e, '') for e in ('mp3', 'wav')])
|
||||
|
||||
export_edl_template : StringProperty(
|
||||
name="Edl Path", default="//render/{project_basename}.edl")
|
||||
|
||||
|
|
Loading…
Reference in New Issue