mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-03-16 03:34:05 +00:00
Revert format check stuff
This commit is contained in:
parent
aaa25eb508
commit
7fb0c05ff6
1 changed files with 15 additions and 25 deletions
|
@ -219,25 +219,15 @@ class FFmpegPostProcessor(PostProcessor):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def stream_copy_opts(copy=True, *, ext=None):
|
def stream_copy_opts(copy=True, *, ext=None):
|
||||||
if ext in ('mkv', 'mka'):
|
yield from ('-map', '0')
|
||||||
yield from ('-map', '0')
|
|
||||||
|
|
||||||
# Some streams, such as JSON attachments, are considered of unknown
|
|
||||||
# type by FFmpeg but we still want to copy them.
|
|
||||||
yield '-copy_unknown'
|
|
||||||
else:
|
|
||||||
# Other containers can get angry at malformed or unknown streams,
|
|
||||||
# so we'll keep only the ones that are "usable".
|
|
||||||
yield from ('-map', '0:u')
|
|
||||||
|
|
||||||
# Most containers don't really like unknown streams. Let's make
|
|
||||||
# sure to get rid of them.
|
|
||||||
yield '-ignore_unknown'
|
|
||||||
|
|
||||||
# Don't copy Apple TV chapters track, bin_data
|
# Don't copy Apple TV chapters track, bin_data
|
||||||
# See https://github.com/yt-dlp/yt-dlp/issues/2, #19042, #19024, https://trac.ffmpeg.org/ticket/6016
|
# See https://github.com/yt-dlp/yt-dlp/issues/2, #19042, #19024, https://trac.ffmpeg.org/ticket/6016
|
||||||
yield '-dn'
|
yield '-dn'
|
||||||
|
|
||||||
|
# Some streams, such as JSON attachments, are considered of unknown
|
||||||
|
# type by FFmpeg but we still want to copy them.
|
||||||
|
yield '-copy_unknown'
|
||||||
|
|
||||||
if copy:
|
if copy:
|
||||||
yield from ('-c', 'copy')
|
yield from ('-c', 'copy')
|
||||||
if ext in ('mp4', 'mov', 'm4a'):
|
if ext in ('mp4', 'mov', 'm4a'):
|
||||||
|
@ -572,7 +562,7 @@ class FFmpegVideoConvertorPP(FFmpegPostProcessor):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _options(target_ext):
|
def _options(target_ext):
|
||||||
yield from FFmpegPostProcessor.stream_copy_opts(False, ext=target_ext)
|
yield from FFmpegPostProcessor.stream_copy_opts(False)
|
||||||
if target_ext == 'avi':
|
if target_ext == 'avi':
|
||||||
yield from ('-c:v', 'libxvid', '-vtag', 'XVID')
|
yield from ('-c:v', 'libxvid', '-vtag', 'XVID')
|
||||||
|
|
||||||
|
@ -598,7 +588,7 @@ class FFmpegVideoRemuxerPP(FFmpegVideoConvertorPP):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _options(target_ext):
|
def _options(target_ext):
|
||||||
return FFmpegPostProcessor.stream_copy_opts(ext=target_ext)
|
return FFmpegPostProcessor.stream_copy_opts()
|
||||||
|
|
||||||
|
|
||||||
class FFmpegEmbedSubtitlePP(FFmpegPostProcessor):
|
class FFmpegEmbedSubtitlePP(FFmpegPostProcessor):
|
||||||
|
@ -674,7 +664,7 @@ class FFmpegEmbedSubtitlePP(FFmpegPostProcessor):
|
||||||
'-map', '-0:s',
|
'-map', '-0:s',
|
||||||
|
|
||||||
'-map', f'{i + 1}:0',
|
'-map', f'{i + 1}:0',
|
||||||
f'-metadata:s:s:{i}', f'language={lang_code}',
|
f'-metadata:s:s:{i}', f'language={lang_code}'
|
||||||
])
|
])
|
||||||
|
|
||||||
if name:
|
if name:
|
||||||
|
@ -710,7 +700,7 @@ class FFmpegMetadataPP(FFmpegPostProcessor):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _options(target_ext):
|
def _options(target_ext):
|
||||||
audio_only = target_ext == 'm4a'
|
audio_only = target_ext == 'm4a'
|
||||||
yield from FFmpegPostProcessor.stream_copy_opts(not audio_only, ext=target_ext)
|
yield from FFmpegPostProcessor.stream_copy_opts(not audio_only)
|
||||||
if audio_only:
|
if audio_only:
|
||||||
yield from ('-vn', '-acodec', 'copy')
|
yield from ('-vn', '-acodec', 'copy')
|
||||||
|
|
||||||
|
@ -909,7 +899,7 @@ class FFmpegFixupStretchedPP(FFmpegFixupPostProcessor):
|
||||||
stretched_ratio = info.get('stretched_ratio')
|
stretched_ratio = info.get('stretched_ratio')
|
||||||
if stretched_ratio not in (None, 1):
|
if stretched_ratio not in (None, 1):
|
||||||
self._fixup('Fixing aspect ratio', info['filepath'], [
|
self._fixup('Fixing aspect ratio', info['filepath'], [
|
||||||
*self.stream_copy_opts(ext=info['ext']), '-aspect', f'{stretched_ratio:f}'])
|
*self.stream_copy_opts(), '-aspect', f'{stretched_ratio:f}'])
|
||||||
return [], info
|
return [], info
|
||||||
|
|
||||||
|
|
||||||
|
@ -917,7 +907,7 @@ class FFmpegFixupM4aPP(FFmpegFixupPostProcessor):
|
||||||
@PostProcessor._restrict_to(images=False, video=False)
|
@PostProcessor._restrict_to(images=False, video=False)
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
if info.get('container') == 'm4a_dash':
|
if info.get('container') == 'm4a_dash':
|
||||||
self._fixup('Correcting container', info['filepath'], [*self.stream_copy_opts(ext=info['ext']), '-f', 'mp4'])
|
self._fixup('Correcting container', info['filepath'], [*self.stream_copy_opts(), '-f', 'mp4'])
|
||||||
return [], info
|
return [], info
|
||||||
|
|
||||||
|
|
||||||
|
@ -940,7 +930,7 @@ class FFmpegFixupM3u8PP(FFmpegFixupPostProcessor):
|
||||||
if self.get_audio_codec(info['filepath']) == 'aac':
|
if self.get_audio_codec(info['filepath']) == 'aac':
|
||||||
args.extend(['-bsf:a', 'aac_adtstoasc'])
|
args.extend(['-bsf:a', 'aac_adtstoasc'])
|
||||||
self._fixup('Fixing MPEG-TS in MP4 container', info['filepath'], [
|
self._fixup('Fixing MPEG-TS in MP4 container', info['filepath'], [
|
||||||
*self.stream_copy_opts(ext=info['ext']), *args])
|
*self.stream_copy_opts(), *args])
|
||||||
return [], info
|
return [], info
|
||||||
|
|
||||||
|
|
||||||
|
@ -961,7 +951,7 @@ class FFmpegFixupTimestampPP(FFmpegFixupPostProcessor):
|
||||||
opts = ['-vf', 'setpts=PTS-STARTPTS']
|
opts = ['-vf', 'setpts=PTS-STARTPTS']
|
||||||
else:
|
else:
|
||||||
opts = ['-c', 'copy', '-bsf', 'setts=ts=TS-STARTPTS']
|
opts = ['-c', 'copy', '-bsf', 'setts=ts=TS-STARTPTS']
|
||||||
self._fixup('Fixing frame timestamp', info['filepath'], [*opts, *self.stream_copy_opts(False, ext=info['ext']), '-ss', self.trim])
|
self._fixup('Fixing frame timestamp', info['filepath'], [*opts, *self.stream_copy_opts(False), '-ss', self.trim])
|
||||||
return [], info
|
return [], info
|
||||||
|
|
||||||
|
|
||||||
|
@ -970,7 +960,7 @@ class FFmpegCopyStreamPP(FFmpegFixupPostProcessor):
|
||||||
|
|
||||||
@PostProcessor._restrict_to(images=False)
|
@PostProcessor._restrict_to(images=False)
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
self._fixup(self.MESSAGE, info['filepath'], self.stream_copy_opts(ext=info['ext']))
|
self._fixup(self.MESSAGE, info['filepath'], self.stream_copy_opts())
|
||||||
return [], info
|
return [], info
|
||||||
|
|
||||||
|
|
||||||
|
@ -1099,7 +1089,7 @@ class FFmpegSplitChaptersPP(FFmpegPostProcessor):
|
||||||
self.to_screen(f'Splitting video by chapters; {len(chapters)} chapters found')
|
self.to_screen(f'Splitting video by chapters; {len(chapters)} chapters found')
|
||||||
for idx, chapter in enumerate(chapters):
|
for idx, chapter in enumerate(chapters):
|
||||||
destination, opts = self._ffmpeg_args_for_chapter(idx + 1, chapter, info)
|
destination, opts = self._ffmpeg_args_for_chapter(idx + 1, chapter, info)
|
||||||
self.real_run_ffmpeg([(in_file, opts)], [(destination, self.stream_copy_opts(ext=info['ext']))])
|
self.real_run_ffmpeg([(in_file, opts)], [(destination, self.stream_copy_opts())])
|
||||||
if in_file != info['filepath']:
|
if in_file != info['filepath']:
|
||||||
self._delete_downloaded_files(in_file, msg=None)
|
self._delete_downloaded_files(in_file, msg=None)
|
||||||
return [], info
|
return [], info
|
||||||
|
|
Loading…
Add table
Reference in a new issue