]> git.parisson.com Git - promaster.git/commitdiff
differentiate in and out frames, overwrite path
authoryomguy <yomguy@parisson.com>
Fri, 14 Dec 2012 11:18:04 +0000 (12:18 +0100)
committeryomguy <yomguy@parisson.com>
Fri, 14 Dec 2012 11:18:04 +0000 (12:18 +0100)
auto_fade.py
kdenlive/fade.py

index 691c5ff4702ab0446201e59639bae6ff56e75651..50e5af3e1830150071ed5c2a9b36f8630bcb9a71 100644 (file)
@@ -1,16 +1,13 @@
 
 import sys
 from kdenlive.fade import AutoFade
-from tempfile import TemporaryFile
-
 
 if __name__ == '__main__':
-    path_out = sys.argv[-1]
-    path_in = sys.argv[-2]
-
-    fade = AutoFade(path_in)
+    path = sys.argv[-1]
+    fade = AutoFade(path)
     data = fade.run()
-    f = open(path_out, 'w')
+    f = open(path, 'w')
     f.write(data)
     f.close()
 
+
index c1f14115831d71f32e494aa2e7732783f9f25067..d6b292148c452b1d1a313459b2b4d11b0bc75c4a 100644 (file)
@@ -31,14 +31,18 @@ class AutoFade(object):
         MLT files are also supported.
     """
 
-    def __init__(self, path, frames=3):
-        self.frames = frames
+    def __init__(self, path, audio_frames_out=2, audio_frames_in=1,
+                       video_frames_out=3, video_frames_in=3):
+        self.audio_frames_in = audio_frames_in
+        self.audio_frames_out = audio_frames_out
+        self.video_frames_in = video_frames_in
+        self.video_frames_out = video_frames_out
         self.path = path
         self.session = xmltodict(self.path)
 
-    def audio_fade_in(self, frame_out):
+    def audio_fade_out(self, frame_out):
         child = {'attributes': {u'id': u'fadeout',
-        u'in': unicode(int(frame_out)-self.frames),
+        u'in': unicode(int(frame_out)-self.audio_frames_out),
         u'out': unicode(frame_out)},
        'children': [{'attributes': {u'name': u'track'},
          'cdata': '0',
@@ -70,10 +74,10 @@ class AutoFade(object):
 
         return child
 
-    def audio_fade_out(self, frame_in):
+    def audio_fade_in(self, frame_in):
         child = {'attributes': {u'id': u'fadein',
         u'in': unicode(frame_in),
-        u'out': unicode(int(frame_in)+self.frames)},
+        u'out': unicode(int(frame_in)+self.audio_frames_in)},
        'children': [{'attributes': {u'name': u'track'},
          'cdata': '0',
          'name': 'property'},
@@ -105,9 +109,9 @@ class AutoFade(object):
         return child
 
 
-    def video_fade_in(self, frame_out):
+    def video_fade_out(self, frame_out):
         child = {'attributes': {u'id': u'fade_to_black',
-        u'in': unicode(int(frame_out)-self.frames),
+        u'in': unicode(int(frame_out)-self.video_frames_out),
         u'out': unicode(frame_out)},
        'children': [{'attributes': {u'name': u'track'},
          'cdata': '0',
@@ -134,10 +138,10 @@ class AutoFade(object):
         return child
 
 
-    def video_fade_out(self, frame_in):
+    def video_fade_in(self, frame_in):
         child = {'attributes': {u'id': u'fade_from_black',
         u'in': unicode(frame_in),
-        u'out': unicode(int(frame_in)+self.frames)},
+        u'out': unicode(int(frame_in)+self.video_frames_in)},
        'children': [{'attributes': {u'name': u'track'},
          'cdata': '0',
          'name': 'property'},
@@ -177,17 +181,17 @@ class AutoFade(object):
 
                             if 'audio' in producer:
                                 if not audio_count % 2:
-                                    att['children'] = [self.audio_fade_in(frame_out)]
+                                    att['children'] = [self.audio_fade_out(frame_out)]
                                 else:
-                                    att['children'] = [self.audio_fade_out(frame_in)]
+                                    att['children'] = [self.audio_fade_in(frame_in)]
                                 audio_count += 1
 
 
                             if 'video' in producer:
                                 if not video_count % 2:
-                                    att['children'] = [self.video_fade_in(frame_out)]
+                                    att['children'] = [self.video_fade_out(frame_out)]
                                 else:
-                                    att['children'] = [self.video_fade_out(frame_in)]
+                                    att['children'] = [self.video_fade_in(frame_in)]
                                 video_count += 1
 
         return dicttoxml(self.session).encode('utf-8')