add generic templates
This commit is contained in:
+42
-17
@@ -16,6 +16,19 @@ import subprocess
|
||||
from collections import defaultdict
|
||||
|
||||
|
||||
def get_render_attributes():
|
||||
scn = bpy.context.scene
|
||||
return [
|
||||
(scn.view_settings, "view_transform", 'Standard'),
|
||||
(scn.render.image_settings, "file_format", 'FFMPEG'),
|
||||
(scn.render.ffmpeg, "gopsize", 8),
|
||||
(scn.render.ffmpeg, "constant_rate_factor", 'HIGH'),
|
||||
(scn.render.ffmpeg, "format", 'QUICKTIME'),
|
||||
(scn.render.ffmpeg, "audio_codec", 'MP3'),
|
||||
(scn.render.ffmpeg, "audio_mixrate", 44100),
|
||||
(scn.render.ffmpeg, "audio_bitrate", 128)
|
||||
]
|
||||
|
||||
def frame_to_timecode(frame, fps):
|
||||
total_seconds = frame / fps
|
||||
|
||||
@@ -109,20 +122,23 @@ def rename_strips(strips, template, increment=10, start_number=0, padding=3, by_
|
||||
strip_number = 0
|
||||
|
||||
for strip in strips:
|
||||
channel = get_channel_name(strip)
|
||||
sequence_name = get_strip_sequence_name(strip)
|
||||
sequence_data = parse(project.sequence_template, sequence_name)
|
||||
format_data = {}
|
||||
if channel == 'Shots':
|
||||
format_data = parse(project.sequence_template, sequence_name)
|
||||
else:
|
||||
format_data['sequence'] = str(strip_number*increment + start_number).zfill(padding)
|
||||
|
||||
if (by_sequence and prev_sequence_name and
|
||||
sequence_name and sequence_name != prev_sequence_name):
|
||||
strip_number = 0
|
||||
|
||||
format_data = dict(
|
||||
format_data.update(
|
||||
sequence_strip=sequence_name,
|
||||
episode=episode_name,
|
||||
shot=str(strip_number*increment + start_number).zfill(padding))
|
||||
|
||||
format_data.update(sequence_data)
|
||||
|
||||
name = template.format(**format_data)
|
||||
|
||||
existing_strip = scn.sequence_editor.sequences_all.get(name)
|
||||
@@ -270,26 +286,32 @@ 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))
|
||||
def render_scene(output, attributes=None):
|
||||
output = os.path.abspath(bpy.path.abspath(str(output)))
|
||||
|
||||
scn = bpy.context.scene
|
||||
render_path = scn.render.filepath
|
||||
|
||||
scn.render.filepath = output
|
||||
if attributes is None:
|
||||
attributes = []
|
||||
|
||||
attributes += [
|
||||
(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))
|
||||
def render_strip(strip, output, attributes=None):
|
||||
output = os.path.abspath(bpy.path.abspath(str(output)))
|
||||
|
||||
scn = bpy.context.scene
|
||||
|
||||
attributes = [
|
||||
if attributes is None:
|
||||
attributes = []
|
||||
|
||||
attributes += [
|
||||
(scn, "frame_start", strip.frame_final_start),
|
||||
(scn, "frame_end", strip.frame_final_end - 1),
|
||||
(scn, "frame_current"),
|
||||
@@ -316,7 +338,6 @@ def import_edit(filepath, adapter="cmx_3600", channel='Shots', match_by='name'):
|
||||
for s in strips:
|
||||
s.channel = empty_channel
|
||||
|
||||
|
||||
edl = Path(filepath)
|
||||
try:
|
||||
timeline = opentimelineio.adapters.read_from_file(
|
||||
@@ -397,11 +418,14 @@ def import_edit(filepath, adapter="cmx_3600", channel='Shots', match_by='name'):
|
||||
scn.frame_end = frame_end-1
|
||||
return timeline
|
||||
|
||||
def import_movie(filepath):
|
||||
def import_movie(filepath, frame_start=None, frame_end=None):
|
||||
scn = bpy.context.scene
|
||||
|
||||
if frame_start is None:
|
||||
frame_start = scn.frame_start
|
||||
|
||||
res_x = scn.render.resolution_x
|
||||
res_y = scn.render.resolution_y
|
||||
res_y = scn.render.resolution_y
|
||||
|
||||
if bpy.data.is_saved:
|
||||
relpath = Path(bpy.path.relpath(str(filepath)))
|
||||
@@ -412,7 +436,7 @@ def import_movie(filepath):
|
||||
name=Path(filepath).stem,
|
||||
filepath=str(filepath),
|
||||
channel=get_channel_index('Movie'),
|
||||
frame_start=scn.frame_start
|
||||
frame_start=frame_start
|
||||
)
|
||||
|
||||
elem = strip.strip_elem_from_frame(scn.frame_current)
|
||||
@@ -423,7 +447,8 @@ def import_movie(filepath):
|
||||
if src_height != res_y:
|
||||
strip.transform.scale_y = (res_y / src_height)
|
||||
|
||||
|
||||
if frame_end is not None:
|
||||
strip.frame_final_end = frame_end
|
||||
|
||||
return strip
|
||||
|
||||
|
||||
Reference in New Issue
Block a user