expose font/size as commandline flags
This commit is contained in:
parent
53cc05c7ff
commit
d1c5f301b0
1 changed files with 14 additions and 8 deletions
16
srt2fcp.py
16
srt2fcp.py
|
@ -265,9 +265,9 @@ sequence_template = '''
|
||||||
def wrap_text(start, end, text, fontsize=30):
|
def wrap_text(start, end, text, fontsize=30):
|
||||||
margin = 40
|
margin = 40
|
||||||
width = 640
|
width = 640
|
||||||
#font = os.path.join(base, 'DejaVuSansCondensedBold.ttf')
|
font = os.path.join(base, 'DejaVuSansCondensedBold.ttf')
|
||||||
|
if not os.path.exists(font):
|
||||||
font = '/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-Bold.ttf'
|
font = '/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-Bold.ttf'
|
||||||
|
|
||||||
n = 10
|
n = 10
|
||||||
alltxt = []
|
alltxt = []
|
||||||
text = ox.strip_tags(ox.decode_html(text))
|
text = ox.strip_tags(ox.decode_html(text))
|
||||||
|
@ -295,8 +295,11 @@ class Fcp:
|
||||||
font = 'Courier New'
|
font = 'Courier New'
|
||||||
#font = 'Lucida Grande'
|
#font = 'Lucida Grande'
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, size=None, font=None):
|
||||||
pass
|
if size is not None:
|
||||||
|
self.fontsize = size
|
||||||
|
if font is not None:
|
||||||
|
self.font = font
|
||||||
|
|
||||||
def add_srt(self, srt, wrap=True):
|
def add_srt(self, srt, wrap=True):
|
||||||
data = ox.srt.load(srt)
|
data = ox.srt.load(srt)
|
||||||
|
@ -343,11 +346,14 @@ class Fcp:
|
||||||
f.write(s)
|
f.write(s)
|
||||||
f.write(fcp_footer)
|
f.write(fcp_footer)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
usage = "usage: %prog srtfile"
|
usage = "usage: %prog srtfile"
|
||||||
parser = OptionParser(usage=usage)
|
parser = OptionParser(usage=usage)
|
||||||
parser.add_option('-w', '--wrap', dest='wrap', help='rewrap text', action="store_true")
|
parser.add_option('-w', '--wrap', dest='wrap', help='rewrap text', action="store_true")
|
||||||
|
parser.add_option('-s', '--size', dest='size', help='font size, default=18', type=int, default=18)
|
||||||
|
parser.add_option('-f', '--font', dest='font', help='font name, default="Courier New"', type=str, default='Courier New')
|
||||||
(opts, args) = parser.parse_args()
|
(opts, args) = parser.parse_args()
|
||||||
|
|
||||||
if not args:
|
if not args:
|
||||||
|
@ -356,6 +362,6 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
srt = args[0]
|
srt = args[0]
|
||||||
output = srt.replace('.srt', '') + '.xml'
|
output = srt.replace('.srt', '') + '.xml'
|
||||||
fcp = Fcp()
|
fcp = Fcp(font=opts.font, size=int(opts.size))
|
||||||
fcp.add_srt(srt, opts.wrap)
|
fcp.add_srt(srt, opts.wrap)
|
||||||
fcp.save(output)
|
fcp.save(output)
|
||||||
|
|
Loading…
Reference in a new issue