[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4125] contrib/py/scripts/addons/ io_sequencer_edl: add EDL importer operators and UI
Campbell Barton
ideasman42 at gmail.com
Thu Jan 3 03:29:48 CET 2013
Revision: 4125
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4125
Author: campbellbarton
Date: 2013-01-03 02:29:41 +0000 (Thu, 03 Jan 2013)
Log Message:
-----------
add EDL importer operators and UI
Modified Paths:
--------------
contrib/py/scripts/addons/io_sequencer_edl/import_edl.py
Added Paths:
-----------
contrib/py/scripts/addons/io_sequencer_edl/__init__.py
Added: contrib/py/scripts/addons/io_sequencer_edl/__init__.py
===================================================================
--- contrib/py/scripts/addons/io_sequencer_edl/__init__.py (rev 0)
+++ contrib/py/scripts/addons/io_sequencer_edl/__init__.py 2013-01-03 02:29:41 UTC (rev 4125)
@@ -0,0 +1,205 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+
+bl_info = {
+ "name": "Import EDL",
+ "author": "Campbell Barton",
+ "version": (1, 0),
+ "blender": (2, 65, 0),
+ "location": "View3D > Add > Mesh > New Object",
+ "description": "Load a CMX formatted EDL into the sequencer",
+ "warning": "",
+ "wiki_url": "",
+ "tracker_url": "",
+ "category": "Import"}
+
+import bpy
+
+
+# ImportHelper is a helper class, defines filename and
+# invoke() function which calls the file selector.
+from bpy_extras.io_utils import ImportHelper
+from bpy.props import (StringProperty,
+ IntProperty,
+ PointerProperty,
+ CollectionProperty,
+ )
+from bpy.types import Operator
+
+# ----------------------------------------------------------------------------
+# Main Operators
+
+
+class ReloadEDL(Operator):
+ bl_idname = "sequencer.import_edl_refresh"
+ bl_label = "Refresh Reels"
+
+ def execute(self, context):
+ import os
+ from . import import_edl
+
+ scene = context.scene
+ edl_import_info = scene.edl_import_info
+
+ filepath = edl_import_info.filepath
+ dummy_fps = 25
+
+ if not os.path.exists(filepath):
+ self.report({'ERROR'}, "File Not Found %r" % filepath)
+ return {'CANCELLED'}
+
+ elist = import_edl.EditList()
+ if not elist.parse(filepath, dummy_fps):
+ self.report({'ERROR'}, "Failed to parse EDL %r" % filepath)
+ return {'CANCELLED'}
+
+ scene = context.scene
+ edl_import_info = scene.edl_import_info
+ bl_reels = edl_import_info.reels
+
+ #scene[EDL_DATA_ID] = {}
+ data_prev = {reel.name: (reel.filepath, reel.frame_offset)
+ for reel in edl_import_info.reels}
+
+ reels = elist.getReels()
+ reels = [k for k in reels.keys() if k != "bw"]
+
+ # re-create reels collection, keeping old values
+ bl_reels.clear()
+ for k in sorted(reels):
+ reel = bl_reels.add()
+ reel.name = k
+ filepath, frame_offset = data_prev.get(k, (None, None))
+ if filepath is not None:
+ reel.filepath = filepath
+ reel.frame_offset = frame_offset
+
+ return {'FINISHED'}
+
+
+class ImportEDL(Operator):
+ """Import an EDL into the sequencer"""
+ bl_idname = "sequencer.import_edl"
+ bl_label = "Import Video Sequence (.edl)"
+
+ def execute(self, context):
+ import os
+ from . import import_edl
+ scene = context.scene
+ edl_import_info = scene.edl_import_info
+
+ filepath = edl_import_info.filepath
+ reel_filepaths = {reel.name: reel.filepath
+ for reel in edl_import_info.reels}
+ reel_offsets = {reel.name: reel.frame_offset
+ for reel in edl_import_info.reels}
+
+ if not os.path.exists(filepath):
+ self.report({'ERROR'}, "File Not Found %r" % filepath)
+ return {'CANCELLED'}
+
+ msg = import_edl.load_edl(
+ scene, filepath,
+ reel_filepaths, reel_offsets)
+
+ if msg:
+ self.report({'WARNING'}, msg)
+
+ return {'FINISHED'}
+
+
+# ----------------------------------------------------------------------------
+# Persistent Scene Data Types (store EDL import info)
+
+class EDLReelInfo(bpy.types.PropertyGroup):
+ name = StringProperty(
+ name="Name",
+ )
+ filepath = StringProperty(
+ name="Video File",
+ subtype='FILE_PATH',
+ )
+ frame_offset = IntProperty(
+ name="Frame Offset",
+ )
+
+
+class EDLImportInfo(bpy.types.PropertyGroup):
+ filepath = StringProperty(
+ subtype='FILE_PATH',
+ )
+ reels = bpy.props.CollectionProperty(
+ type=EDLReelInfo,
+ )
+
+
+# ----------------------------------------------------------------------------
+# Panel to show EDL Import UI
+
+
+class SEQUENCER_PT_import_edl(bpy.types.Panel):
+ bl_label = "EDL Import"
+ bl_space_type = 'SEQUENCE_EDITOR'
+ bl_region_type = 'UI'
+
+ def draw(self, context):
+ layout = self.layout
+
+ scene = context.scene
+ edl_import_info = scene.edl_import_info
+
+ layout.operator("sequencer.import_edl")
+
+ col = layout.column(align=True)
+ col.prop(edl_import_info, "filepath", text="")
+ col.operator("sequencer.import_edl_refresh", icon='FILE_REFRESH')
+
+ box = layout.box()
+ reel = None
+ for reel in scene.edl_import_info.reels:
+ col = box.column(align=True)
+ col.label(text=reel.name)
+ col.prop(reel, "filepath", text="")
+ col.prop(reel, "frame_offset")
+
+ if reel is None:
+ box.label("Empty (No EDL Data)")
+
+
+def register():
+ bpy.utils.register_class(ReloadEDL)
+ bpy.utils.register_class(ImportEDL)
+ bpy.utils.register_class(SEQUENCER_PT_import_edl)
+
+ # types
+ bpy.utils.register_class(EDLReelInfo)
+ bpy.utils.register_class(EDLImportInfo)
+ bpy.types.Scene.edl_import_info = PointerProperty(type=EDLImportInfo)
+
+
+def unregister():
+ bpy.utils.unregister_class(ReloadEDL)
+ bpy.utils.unregister_class(ImportEDL)
+ bpy.utils.unregister_class(SEQUENCER_PT_import_edl)
+
+ # types
+ bpy.utils.unregister_class(EDLImportInfo)
+ bpy.utils.unregister_class(EDLReelInfo)
+ del bpy.types.Scene.edl_import_info
Property changes on: contrib/py/scripts/addons/io_sequencer_edl/__init__.py
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: contrib/py/scripts/addons/io_sequencer_edl/import_edl.py
===================================================================
--- contrib/py/scripts/addons/io_sequencer_edl/import_edl.py 2013-01-03 01:18:58 UTC (rev 4124)
+++ contrib/py/scripts/addons/io_sequencer_edl/import_edl.py 2013-01-03 02:29:41 UTC (rev 4125)
@@ -18,14 +18,7 @@
# <pep8 compliant>
-"""
-Name: "Video Sequence (.edl)..."
-Blender: 248
-Group: "Import"
-Tooltip: "Load a CMX formatted EDL into the sequencer"
-"""
-
class TimeCode:
"""
Simple timecode class
@@ -38,6 +31,7 @@
"seconds",
"frame",
)
+
def __init__(self, data, fps):
self.fps = fps
if type(data) == str:
@@ -315,7 +309,7 @@
self.custom_data = [] # use for storing any data you want (blender strip for eg)
- if text != None:
+ if text is not None:
self.read(text, fps)
def __repr__(self):
@@ -595,14 +589,13 @@
def scale_meta_speed(sequence_editor, mov, scale):
# Add an effect
#speed = sequence_editor.new((SEQ_SPEED, mov,), 199, mov.channel + 1)
- dummy_frame=0
+ dummy_frame = 0
speed = sequence_editor.sequences.new_effect(name="Speed", type='SPEED', seq1=mov, start_frame=dummy_frame, channel=mov.channel + 1)
-
+
# not working in 2.6x :|
speed.use_frame_blend = True
#meta = sequence_editor.new([mov, speed], 199, mov.channel)
-
# XXX-Meta Operator Mess
scene = sequence_editor.id_data
for seq in scene.sequence_editor.sequences_all:
@@ -613,7 +606,6 @@
meta = scene.sequence_editor.sequences[-1]
# XXX-Meta Operator Mess (END)
-
if scale >= 1.0:
mov.frame_still_end = int(mov.frame_duration * (scale - 1.0))
else:
@@ -629,12 +621,12 @@
scene = mov.id_data
id_animdata_action_ensure(scene)
action = scene.animation_data.action
-
+
data_path = mov.path_from_id("blend_alpha")
blend_alpha_fcurve = action.fcurves.new(data_path, index=0)
blend_alpha_fcurve.keyframe_points.insert(mov.frame_final_start, 0.0)
blend_alpha_fcurve.keyframe_points.insert(mov.frame_final_end, 1.0)
-
+
blend_alpha_fcurve.keyframe_points[0].interpolation = 'LINEAR'
blend_alpha_fcurve.keyframe_points[1].interpolation = 'LINEAR'
@@ -645,7 +637,7 @@
def replace_ext(path, ext):
return path[:path.rfind(".") + 1] + ext
-TODO_SPEED_SUPPORT = True
+
def load_edl(scene, filename, reel_files, reel_offsets):
"""
reel_files - key:reel <--> reel:filename
@@ -686,7 +678,7 @@
# print src_length, rec_length, src_start
- if edit.m2 != None:
+ if edit.m2 is not None:
scale = fps / edit.m2.fps
else:
scale = 1.0
@@ -717,7 +709,7 @@
# return "Invalid input for movie"
# Apply scaled rec in bounds
- if scale != 1.0 and TODO_SPEED_SUPPORT:
+ if scale != 1.0:
meta = scale_meta_speed(sequence_editor, strip, scale)
final_strip = meta
else:
@@ -751,7 +743,7 @@
#strip_wipe = sequence_editor.new((SEQ_WIPE, other, final_strip), 1, other_track)
strip_wipe = sequence_editor.sequences.new_effect(name="Wipe", type='WIPE', seq1=final_strip, start_frame=dummy_frame, channel=other_track)
-
+
from math import radians
if edit.wipe_type == WIPE_0:
strip_wipe.angle = radians(+90)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list