Пример #1
0
 def setUp(self):
     test_content = StringIO(u"""
     0:00:03.490,0:00:07.430
     >> FISHER: All right. So, let's begin.
     This session is: Going Social
     
     0:00:07.430,0:00:11.600
     with the YouTube APIs. I am
     Jeff Fisher,
     
     0:00:11.600,0:00:14.009
     and this is Johann Hartmann,
     we're presenting today.
     
     0:00:14.009,0:00:15.889
     [pause]
     """)
     self.reader = Reader(test_content)
Пример #2
0
				of = f'{of[:(-5-len(str(counter - 1)))]}-{counter}{of[-4:]}'
				counter += 1
	elif os.path.isfile(of):
		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