1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-24 11:11:54 +00:00

[embedthumbnail] use ffmpeg to m4a/mp4 if version >= 4.0

This commit is contained in:
kikuyan 2021-07-20 08:42:44 +09:00
parent a803582717
commit 56e9fda73a

View file

@ -11,6 +11,7 @@ from ..utils import (
check_executable,
encodeArgument,
encodeFilename,
is_outdated_version,
PostProcessingError,
prepend_extension,
replace_extension,
@ -89,6 +90,28 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
os.rename(encodeFilename(temp_filename), encodeFilename(filename))
elif info['ext'] in ['m4a', 'mp4']:
# use ffmpeg if the version supports embedding thumbnails
if self.basename == 'ffmpeg' and not is_outdated_version(self._lavf_version.get('build'), '58.12.100', False): # ffmpeg >= 4.0
if info['ext'] == 'm4a':
disposition = 0
else:
disposition = 1
options = [
'-c', 'copy', '-map', '0', '-map', '1',
'-disposition:v:%s' % disposition,
'attached_pic'
]
self._downloader.to_screen('[ffmpeg] Adding thumbnail to "%s"' % filename)
self.run_ffmpeg_multiple_files([filename, thumbnail_filename], temp_filename, options)
if not self._already_have_thumbnail:
os.remove(encodeFilename(thumbnail_filename))
os.remove(encodeFilename(filename))
os.rename(encodeFilename(temp_filename), encodeFilename(filename))
return [], info
atomicparsley = next((x
for x in ['AtomicParsley', 'atomicparsley']
if check_executable(x, ['-v'])), None)