def setUp(self): test_content = StringIO(u"""1 00:00:03,490 --> 00:00:07,430 FISHER: All right. So, let's begin. This session is: Going Social 00:00:07,430 --> 00:00:11,600 with the YouTube APIs. I am Jeff Fisher, 2 00:00:11,600 --> 00:00:14,009 and this is Johann Hartmann, we're presenting today. 3 00:00:14,009 --> 00:00:15,889 [pause] """) self.reader = Reader(test_content) self.writer = Writer(StringIO())
counter = 1 of = f'{of[:-4]}-{counter}{of[-4:]}' while os.path.isfile(of): of = f'{of[:(-5-len(str(counter - 1)))]}-{counter}{of[-4:]}' counter += 1 # Convert sbv to srt to add them if os.path.splitext(sf)[1] == '.sbv': from captionstransformer.sbv import Reader from captionstransformer.srt import Writer with open(sf) as r: reader = Reader(r) with open(f'{os.path.splitext(sf)[0]}.srt', 'w') as w: writer = Writer(w) writer.set_captions(reader.read()) writer.write() writer.close() print(f'Adding subtitles to {vf}...') if not args.soft_embed: subprocess.call(f'ffmpeg -hide_banner -loglevel warning -i "{vf}" -vf "subtitles=\'{sf}\':force_style=\'Fontsize={args.size},PrimaryColour=&H{args.color}&,BorderStyle={args.border_style}{args.additional_formatting}\'" -c:v {codec_string} -c:a copy "{of}"', cwd = os.getcwd(), shell = True) else: subprocess.call(f'ffmpeg -hide_banner -loglevel warning -i "{vf}" -i "{sf}" -c:v {codec_string} -c:a copy -c:s mov_text -disposition:s:0 default "{of}"', cwd = os.getcwd(), shell = True) # If the subtitle started off as sbv, try to delete the temporarily needed srt file # This isn't hugely important, so just pass if it fails if os.path.splitext(sf)[1] == '.sbv': try: