Skip to content
Snippets Groups Projects
Commit 2e293107 authored by Campbell Barton's avatar Campbell Barton
Browse files

fixes to EDL import

- allow editmode 'a1', 'a2', 'a3'... etc
- allow editmode 'none'
- accept black as 'bl', 'bw', 'blk', 'black'
- black was being imported as grey
- add global frame offset option for importing
- fix error naming strips
- if a reel has an extension, match with the extension stripped as well --- so foobar.mov will find foobar.avi file.
parent 8a83ea85
No related branches found
No related tags found
No related merge requests found
...@@ -79,7 +79,7 @@ class ReloadEDL(Operator): ...@@ -79,7 +79,7 @@ class ReloadEDL(Operator):
for reel in edl_import_info.reels} for reel in edl_import_info.reels}
reels = elist.reels_as_dict() reels = elist.reels_as_dict()
reels = [k for k in reels.keys() if k != "bw"] reels = [k for k in reels.keys() if k not in parse_edl.BLACK_ID]
# re-create reels collection, keeping old values # re-create reels collection, keeping old values
bl_reels.clear() bl_reels.clear()
...@@ -116,6 +116,7 @@ class FindReelsEDL(Operator): ...@@ -116,6 +116,7 @@ class FindReelsEDL(Operator):
# walk over .avi, .mov, .wav etc. # walk over .avi, .mov, .wav etc.
def media_file_walker(path): def media_file_walker(path):
ext_check = bpy.path.extensions_movie | bpy.path.extensions_audio
for dirpath, dirnames, filenames in os.walk(path): for dirpath, dirnames, filenames in os.walk(path):
# skip '.svn' # skip '.svn'
if dirpath.startswith("."): if dirpath.startswith("."):
...@@ -123,9 +124,7 @@ class FindReelsEDL(Operator): ...@@ -123,9 +124,7 @@ class FindReelsEDL(Operator):
for filename in filenames: for filename in filenames:
fileonly, ext = os.path.splitext(filename) fileonly, ext = os.path.splitext(filename)
ext_lower = ext.lower() ext_lower = ext.lower()
if ext_lower in bpy.path.extensions_movie: if ext_lower in ext_check:
yield os.path.join(dirpath, filename), fileonly
elif ext_lower in bpy.path.extensions_audio:
yield os.path.join(dirpath, filename), fileonly yield os.path.join(dirpath, filename), fileonly
scene = context.scene scene = context.scene
...@@ -143,6 +142,11 @@ class FindReelsEDL(Operator): ...@@ -143,6 +142,11 @@ class FindReelsEDL(Operator):
for reel_names, reel_files_found, reel in bl_reels_search: for reel_names, reel_files_found, reel in bl_reels_search:
reel_names_list = [] reel_names_list = []
reel_names_list.append(reel.name.lower()) reel_names_list.append(reel.name.lower())
# add non-extension version of the reel name
if "." in reel_names_list[-1]:
reel_names_list.append(os.path.splitext(reel_names_list[-1])[0])
# use the filepath if set # use the filepath if set
reel_filepath = reel.filepath reel_filepath = reel.filepath
if reel_filepath: if reel_filepath:
...@@ -156,6 +160,12 @@ class FindReelsEDL(Operator): ...@@ -156,6 +160,12 @@ class FindReelsEDL(Operator):
if "_" in reel_filepath] if "_" in reel_filepath]
reel_names.update(reel_names_list) reel_names.update(reel_names_list)
# debug info
print("Searching or %d reels" % len(bl_reels_search))
for reel_names, reel_files_found, reel in bl_reels_search:
print("Reel: %r --> (%s)" % (reel.name, " ".join(sorted(reel_names))))
print()
for filename, fileonly in media_file_walker(self.directory): for filename, fileonly in media_file_walker(self.directory):
for reel_names, reel_files_found, reel in bl_reels_search: for reel_names, reel_files_found, reel in bl_reels_search:
if fileonly.lower() in reel_names: if fileonly.lower() in reel_names:
...@@ -227,7 +237,8 @@ class ImportEDL(Operator): ...@@ -227,7 +237,8 @@ class ImportEDL(Operator):
msg = import_edl.load_edl( msg = import_edl.load_edl(
scene, filepath, scene, filepath,
reel_filepaths, reel_offsets) reel_filepaths, reel_offsets,
edl_import_info.frame_offset)
if msg: if msg:
self.report({'WARNING'}, msg) self.report({'WARNING'}, msg)
...@@ -258,7 +269,9 @@ class EDLImportInfo(bpy.types.PropertyGroup): ...@@ -258,7 +269,9 @@ class EDLImportInfo(bpy.types.PropertyGroup):
reels = bpy.props.CollectionProperty( reels = bpy.props.CollectionProperty(
type=EDLReelInfo, type=EDLReelInfo,
) )
frame_offset = IntProperty(
name="Global Frame Offset",
)
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Panel to show EDL Import UI # Panel to show EDL Import UI
...@@ -278,6 +291,7 @@ class SEQUENCER_PT_import_edl(bpy.types.Panel): ...@@ -278,6 +291,7 @@ class SEQUENCER_PT_import_edl(bpy.types.Panel):
layout.operator(ImportEDL.bl_idname) layout.operator(ImportEDL.bl_idname)
col = layout.column(align=True) col = layout.column(align=True)
col.prop(edl_import_info, "frame_offset")
col.prop(edl_import_info, "filepath", text="") col.prop(edl_import_info, "filepath", text="")
col.operator(ReloadEDL.bl_idname, icon='FILE_REFRESH') col.operator(ReloadEDL.bl_idname, icon='FILE_REFRESH')
......
...@@ -89,7 +89,7 @@ def replace_ext(path, ext): ...@@ -89,7 +89,7 @@ def replace_ext(path, ext):
return path[:path.rfind(".") + 1] + ext return path[:path.rfind(".") + 1] + ext
def load_edl(scene, filename, reel_files, reel_offsets): def load_edl(scene, filename, reel_files, reel_offsets, global_offset):
""" """
reel_files - key:reel <--> reel:filename reel_files - key:reel <--> reel:filename
""" """
...@@ -123,7 +123,10 @@ def load_edl(scene, filename, reel_files, reel_offsets): ...@@ -123,7 +123,10 @@ def load_edl(scene, filename, reel_files, reel_offsets):
prev_edit = None prev_edit = None
for edit in edits: for edit in edits:
print(edit) print(edit)
frame_offset = reel_offsets[edit.reel] if edit.reel.lower() in parse_edl.BLACK_ID:
frame_offset = 0
else:
frame_offset = reel_offsets[edit.reel]
src_start = int(edit.srcIn) + frame_offset src_start = int(edit.srcIn) + frame_offset
src_end = int(edit.srcOut) + frame_offset src_end = int(edit.srcOut) + frame_offset
...@@ -133,6 +136,10 @@ def load_edl(scene, filename, reel_files, reel_offsets): ...@@ -133,6 +136,10 @@ def load_edl(scene, filename, reel_files, reel_offsets):
rec_end = int(edit.recOut) + 1 rec_end = int(edit.recOut) + 1
rec_length = rec_end - rec_start rec_length = rec_end - rec_start
# apply global offset
rec_start += global_offset
rec_end += global_offset
# print src_length, rec_length, src_start # print src_length, rec_length, src_start
if edit.m2 is not None: if edit.m2 is not None:
...@@ -148,16 +155,17 @@ def load_edl(scene, filename, reel_files, reel_offsets): ...@@ -148,16 +155,17 @@ def load_edl(scene, filename, reel_files, reel_offsets):
strip = None strip = None
final_strips = [] final_strips = []
if edit.reel.lower() == "bw": if edit.reel.lower() in parse_edl.BLACK_ID:
strip = sequence_editor.sequences.new_effect( strip = sequence_editor.sequences.new_effect(
name="Wipe", name="Color",
type='COLOR', type='COLOR',
start_frame=rec_start, start_frame=rec_start,
end_frame=rec_start + max(1, rec_length),
channel=track + 1) channel=track + 1)
strip_list.append(strip) strip_list.append(strip)
strip.frame_duration = rec_length # for color its simple
final_strips.append(strip) final_strips.append(strip)
strip.color = 0.0, 0.0, 0.0
else: else:
path_full = reel_files[edit.reel] path_full = reel_files[edit.reel]
path_dironly, path_fileonly = os.path.split(path_full) path_dironly, path_fileonly = os.path.split(path_full)
...@@ -272,7 +280,7 @@ def load_edl(scene, filename, reel_files, reel_offsets): ...@@ -272,7 +280,7 @@ def load_edl(scene, filename, reel_files, reel_offsets):
if final_strips: if final_strips:
for strip in final_strips: for strip in final_strips:
# strip.frame_duration = length # strip.frame_duration = length
final_strip.name = edit.as_name() strip.name = edit.as_name()
edit.custom_data[:] = final_strips edit.custom_data[:] = final_strips
# track = not track # track = not track
prev_edit = edit prev_edit = edit
......
...@@ -223,9 +223,9 @@ EDIT_VIDEO_AUDIO = 1 << enum ...@@ -223,9 +223,9 @@ EDIT_VIDEO_AUDIO = 1 << enum
enum += 1 enum += 1
EDIT_DICT = { EDIT_DICT = {
"none": 0, # TODO, investigate this more.
"v": EDIT_VIDEO, "v": EDIT_VIDEO,
"a": EDIT_AUDIO, "a": EDIT_AUDIO,
"a2": EDIT_AUDIO, # TODO, what is this really?, FCP uses.
"aa": EDIT_AUDIO_STEREO, "aa": EDIT_AUDIO_STEREO,
"va": EDIT_VIDEO_AUDIO, "va": EDIT_VIDEO_AUDIO,
"b": EDIT_VIDEO_AUDIO, "b": EDIT_VIDEO_AUDIO,
...@@ -248,6 +248,13 @@ enum += 1 ...@@ -248,6 +248,13 @@ enum += 1
KEY_OUT = enum # K O KEY_OUT = enum # K O
enum += 1 enum += 1
BLACK_ID = {
"bw",
"bl",
"blk",
"black",
}
""" """
Most sytems: Most sytems:
...@@ -290,6 +297,10 @@ class EditDecision: ...@@ -290,6 +297,10 @@ class EditDecision:
def edit_flags_to_text(flag): def edit_flags_to_text(flag):
return "/".join([item for item, val in EDIT_DICT.items() if val & flag]) return "/".join([item for item, val in EDIT_DICT.items() if val & flag])
@staticmethod
def strip_digits(text):
return "".join(filter(lambda x: not x.isdigit(), text))
def __init__(self, text=None, fps=25): def __init__(self, text=None, fps=25):
# print text # print text
self.number = -1 self.number = -1
...@@ -351,7 +362,8 @@ class EditDecision: ...@@ -351,7 +362,8 @@ class EditDecision:
# AA/V can be an edit type # AA/V can be an edit type
self.edit_type = 0 self.edit_type = 0
for edit_type in line[index].lower().split("/"): for edit_type in line[index].lower().split("/"):
self.edit_type |= EDIT_DICT[edit_type] # stripping digits is done because we don't do 'a1, a2...'
self.edit_type |= EDIT_DICT[EditDecision.strip_digits(edit_type)]
index += 1 index += 1
tx_name = "".join([c for c in line[index].lower() if not c.isdigit()]) tx_name = "".join([c for c in line[index].lower() if not c.isdigit()])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment