diff --git a/fcp2srt.py b/fcp2srt.py index c29b2c9..9d49f70 100755 --- a/fcp2srt.py +++ b/fcp2srt.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from __future__ import division import lxml @@ -39,5 +39,5 @@ for g in tree.xpath('//generatoritem'): 'in': _start/fps, 'out': (_end-1)/fps, 'value': value }) -with open(target, 'w') as f: +with open(target, 'wb') as f: f.write(ox.srt.encode(data)) diff --git a/srt2fcp.py b/srt2fcp.py index 8396b67..994e641 100755 --- a/srt2fcp.py +++ b/srt2fcp.py @@ -18,7 +18,7 @@ from PIL import Image base = os.path.abspath(os.path.dirname(__file__)) -generator_template = ''' +generator_template = ''' Text 3000 @@ -219,18 +219,18 @@ sequence_template = ''' 24 - Apple DV - PAL + Apple ProRes 422 Final Cut Pro Apple Inc. 7.0 - Apple DV - PAL - DV - PAL - dvcp + Apple ProRes 422 + Apple ProRes 422 + apcn appl - 1023 + 1024 0 0 0 @@ -294,6 +294,7 @@ class Fcp: fontsize = 18 font = 'Courier New' #font = 'Lucida Grande' + gid = 0 def __init__(self, size=None, font=None): if size is not None: @@ -329,8 +330,10 @@ class Fcp: }) def sub(self, start, end, text): - text = xml.sax.saxutils.escape('\n'.join(text).strip()).replace('\n', ' ') + self.gid += 1 + text = xml.sax.saxutils.escape('\n'.join(text).strip()).replace('\n', ' ') return generator_template % { + 'id': self.gid, 'start': start, 'end': end, 'duration': end-start,