[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, check_executable,
encodeArgument, encodeArgument,
encodeFilename, encodeFilename,
is_outdated_version,
PostProcessingError, PostProcessingError,
prepend_extension, prepend_extension,
replace_extension, replace_extension,
@ -89,6 +90,28 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
os.rename(encodeFilename(temp_filename), encodeFilename(filename)) os.rename(encodeFilename(temp_filename), encodeFilename(filename))
elif info['ext'] in ['m4a', 'mp4']: 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 atomicparsley = next((x
for x in ['AtomicParsley', 'atomicparsley'] for x in ['AtomicParsley', 'atomicparsley']
if check_executable(x, ['-v'])), None) if check_executable(x, ['-v'])), None)