[postprocessort/ffmpeg] Allow embedding webvtt into webm (Closes #8874)
parent
5c7cd37ebd
commit
40025ee2a3
|
@ -720,7 +720,7 @@ def parseOpts(overrideArguments=None):
|
||||||
postproc.add_option(
|
postproc.add_option(
|
||||||
'--embed-subs',
|
'--embed-subs',
|
||||||
action='store_true', dest='embedsubtitles', default=False,
|
action='store_true', dest='embedsubtitles', default=False,
|
||||||
help='Embed subtitles in the video (only for mkv and mp4 videos)')
|
help='Embed subtitles in the video (only for mp4, webm and mkv videos)')
|
||||||
postproc.add_option(
|
postproc.add_option(
|
||||||
'--embed-thumbnail',
|
'--embed-thumbnail',
|
||||||
action='store_true', dest='embedthumbnail', default=False,
|
action='store_true', dest='embedthumbnail', default=False,
|
||||||
|
|
|
@ -331,17 +331,34 @@ class FFmpegVideoConvertorPP(FFmpegPostProcessor):
|
||||||
|
|
||||||
class FFmpegEmbedSubtitlePP(FFmpegPostProcessor):
|
class FFmpegEmbedSubtitlePP(FFmpegPostProcessor):
|
||||||
def run(self, information):
|
def run(self, information):
|
||||||
if information['ext'] not in ['mp4', 'mkv']:
|
if information['ext'] not in ('mp4', 'webm', 'mkv'):
|
||||||
self._downloader.to_screen('[ffmpeg] Subtitles can only be embedded in mp4 or mkv files')
|
self._downloader.to_screen('[ffmpeg] Subtitles can only be embedded in mp4, webm or mkv files')
|
||||||
return [], information
|
return [], information
|
||||||
subtitles = information.get('requested_subtitles')
|
subtitles = information.get('requested_subtitles')
|
||||||
if not subtitles:
|
if not subtitles:
|
||||||
self._downloader.to_screen('[ffmpeg] There aren\'t any subtitles to embed')
|
self._downloader.to_screen('[ffmpeg] There aren\'t any subtitles to embed')
|
||||||
return [], information
|
return [], information
|
||||||
|
|
||||||
sub_langs = list(subtitles.keys())
|
|
||||||
filename = information['filepath']
|
filename = information['filepath']
|
||||||
sub_filenames = [subtitles_filename(filename, lang, sub_info['ext']) for lang, sub_info in subtitles.items()]
|
|
||||||
|
ext = information['ext']
|
||||||
|
sub_langs = []
|
||||||
|
sub_filenames = []
|
||||||
|
webm_vtt_warn = False
|
||||||
|
|
||||||
|
for lang, sub_info in subtitles.items():
|
||||||
|
sub_ext = sub_info['ext']
|
||||||
|
if ext != 'webm' or ext == 'webm' and sub_ext == 'vtt':
|
||||||
|
sub_langs.append(lang)
|
||||||
|
sub_filenames.append(subtitles_filename(filename, lang, sub_ext))
|
||||||
|
else:
|
||||||
|
if not webm_vtt_warn and ext == 'webm' and sub_ext != 'vtt':
|
||||||
|
webm_vtt_warn = True
|
||||||
|
self._downloader.to_screen('[ffmpeg] Only WebVTT subtitles can be embedded in webm files')
|
||||||
|
|
||||||
|
if not sub_langs:
|
||||||
|
return [], information
|
||||||
|
|
||||||
input_files = [filename] + sub_filenames
|
input_files = [filename] + sub_filenames
|
||||||
|
|
||||||
opts = [
|
opts = [
|
||||||
|
|
Loading…
Reference in New Issue