From: yomguy Date: Fri, 14 Dec 2012 11:18:04 +0000 (+0100) Subject: differentiate in and out frames, overwrite path X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=bcece7914b11c953e67e8effe5d3aa909b9d6804;p=promaster.git differentiate in and out frames, overwrite path --- diff --git a/auto_fade.py b/auto_fade.py index 691c5ff..50e5af3 100644 --- a/auto_fade.py +++ b/auto_fade.py @@ -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() + diff --git a/kdenlive/fade.py b/kdenlive/fade.py index c1f1411..d6b2921 100644 --- a/kdenlive/fade.py +++ b/kdenlive/fade.py @@ -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')