export background
This commit is contained in:
@@ -0,0 +1,183 @@
|
||||
|
||||
import time
|
||||
import re
|
||||
from pathlib import Path
|
||||
import os
|
||||
|
||||
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.bl_utils import (get_scene_settings, background_render)
|
||||
from vse_toolbox.file_utils import install_module
|
||||
|
||||
|
||||
|
||||
class VSETB_OT_render(Operator):
|
||||
bl_idname = "vse_toolbox.strips_render"
|
||||
bl_label = "Render Shots Strips"
|
||||
bl_description = "Render Shots Strips"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
#selected_only : BoolProperty(name="Selected Only", default=False)
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
settings = get_scene_settings()
|
||||
return settings.active_project
|
||||
|
||||
def invoke(self, context, event):
|
||||
scn = context.scene
|
||||
settings = get_scene_settings()
|
||||
|
||||
return context.window_manager.invoke_props_dialog(self)
|
||||
|
||||
def draw(self, context):
|
||||
scn = context.scene
|
||||
settings = get_scene_settings()
|
||||
|
||||
layout = self.layout
|
||||
col = layout.column()
|
||||
#col.use_property_split = True
|
||||
#col.use_property_decorate = False
|
||||
|
||||
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")
|
||||
|
||||
col.separator()
|
||||
col.prop(settings.active_project, "render_per_strip")
|
||||
row = col.row()
|
||||
row.enabled = settings.active_project.render_per_strip
|
||||
row.prop(settings.active_project, "render_strip_template")
|
||||
|
||||
#col.prop(settings, 'channel', text='Channel')
|
||||
#col.prop(self, 'selected_only')
|
||||
|
||||
def execute(self, context):
|
||||
scn = context.scene
|
||||
settings = get_scene_settings()
|
||||
project = settings.active_project
|
||||
|
||||
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)
|
||||
render_strip(strip, strip_render_path)
|
||||
|
||||
self.report({"INFO"}, f'Strips rendered in {time.perf_counter()-start_time} seconds')
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class VSETB_OT_export_edl(Operator):
|
||||
bl_idname = "vse_toolbox.export_edl"
|
||||
bl_label = "Export Edl"
|
||||
bl_description = "Export Edl"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
#selected_only : BoolProperty(name="Selected Only", default=False)
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
settings = get_scene_settings()
|
||||
return settings.active_project
|
||||
|
||||
def invoke(self, context, event):
|
||||
scn = context.scene
|
||||
settings = get_scene_settings()
|
||||
|
||||
return context.window_manager.invoke_props_dialog(self)
|
||||
|
||||
def draw(self, context):
|
||||
scn = context.scene
|
||||
settings = get_scene_settings()
|
||||
|
||||
layout = self.layout
|
||||
col = layout.column()
|
||||
col.use_property_split = True
|
||||
col.use_property_decorate = False
|
||||
#col.prop(settings, 'channel', text='Channel')
|
||||
#col.prop(self, 'selected_only')
|
||||
|
||||
col.prop(settings.active_project, "export_edl_template")
|
||||
|
||||
def execute(self, context):
|
||||
opentimelineio = install_module('opentimelineio')
|
||||
|
||||
from opentimelineio.schema import (Clip, Timeline, Track, ExternalReference)
|
||||
from opentimelineio.opentime import (RationalTime, TimeRange)
|
||||
|
||||
start_time = time.perf_counter()
|
||||
|
||||
scn = context.scene
|
||||
settings = get_scene_settings()
|
||||
fps = scn.render.fps
|
||||
|
||||
project = settings.active_project
|
||||
|
||||
format_data = {**settings.format_data, **project.format_data}
|
||||
output_edl = project.export_edl_template.format(**format_data)
|
||||
output_edl = os.path.abspath(bpy.path.abspath(output_edl))
|
||||
output_edl = Path(output_edl)
|
||||
|
||||
|
||||
timeline = Timeline(output_edl.stem)
|
||||
track = Track(f"Track 1")
|
||||
track.kind = "Video"
|
||||
|
||||
timeline.tracks.append(track)
|
||||
|
||||
for strip in get_strips(channel='Shots', selected_only=False):
|
||||
strip_data = {**format_data, **strip.vsetb_strip_settings.format_data}
|
||||
strip_render_path = project.render_strip_template.format(**strip_data)
|
||||
|
||||
clip = Clip(Path(strip_render_path).name)
|
||||
|
||||
clip.metadata.setdefault("cmx_3600", {})
|
||||
clip.metadata['cmx_3600']['reel'] = strip.name
|
||||
#clip.metadata['cmx_3600']['flags'] = 'IS_CLIP'
|
||||
|
||||
#clip.media_reference = ExternalReference(f'//render/{strip.name}.mov')
|
||||
#clip.media_reference.name = strip.name
|
||||
|
||||
#clip.available_range = TimeRange(RationalTime(0, fps), RationalTime(strip.frame_duration, fps))
|
||||
clip.source_range = TimeRange(RationalTime(strip.frame_offset_start, fps), RationalTime(strip.frame_final_duration, fps))
|
||||
|
||||
track.append(clip)
|
||||
|
||||
output_edl.parent.mkdir(exist_ok=True, parents=True)
|
||||
|
||||
edl = opentimelineio.adapters.write_to_string(timeline, 'cmx_3600')
|
||||
output_edl.write_text(edl)
|
||||
#opentimelineio.adapters.write_to_file(timeline, str(output_edl), 'cmx_3600')
|
||||
|
||||
self.report({"INFO"}, f'Edl Exported in {time.perf_counter()-start_time} seconds')
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
||||
|
||||
classes = (
|
||||
VSETB_OT_render,
|
||||
VSETB_OT_export_edl
|
||||
)
|
||||
|
||||
def register():
|
||||
for cls in classes:
|
||||
bpy.utils.register_class(cls)
|
||||
|
||||
def unregister():
|
||||
for cls in reversed(classes):
|
||||
bpy.utils.unregister_class(cls)
|
||||
Reference in New Issue
Block a user