X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=youtube_dl%2Fpostprocessor%2Fembedthumbnail.py;h=4868a42fdca9f486bed5e1def3ffaf08b26fda39;hb=233c1c0e76d64c9e13dc8968bfd8a014c49e66a8;hp=b6507db272a81f1e0ce3880be74c6015ec006f93;hpb=ddbed36455f8b3053f38d84b2e62e2fb5cd66eac;p=youtube-dl.git diff --git a/youtube_dl/postprocessor/embedthumbnail.py b/youtube_dl/postprocessor/embedthumbnail.py index b6507db27..4868a42fd 100644 --- a/youtube_dl/postprocessor/embedthumbnail.py +++ b/youtube_dl/postprocessor/embedthumbnail.py @@ -5,11 +5,13 @@ from __future__ import unicode_literals import os import subprocess -from .common import PostProcessor +from .ffmpeg import FFmpegPostProcessor + from ..compat import ( compat_urlretrieve, ) from ..utils import ( + determine_ext, check_executable, encodeFilename, PostProcessingError, @@ -22,11 +24,11 @@ class EmbedThumbnailPPError(PostProcessingError): pass -class EmbedThumbnailPP(PostProcessor): +class EmbedThumbnailPP(FFmpegPostProcessor): def run(self, info): filename = info['filepath'] temp_filename = prepend_extension(filename, 'temp') - temp_thumbnail = prepend_extension(filename, 'thumb') + temp_thumbnail = filename + '.' + determine_ext(info['thumbnail']) if not info.get('thumbnail'): raise EmbedThumbnailPPError('Thumbnail was not found. Nothing to do.') @@ -34,22 +36,13 @@ class EmbedThumbnailPP(PostProcessor): compat_urlretrieve(info['thumbnail'], temp_thumbnail) if info['ext'] == 'mp3': - if not check_executable('ffmpeg', ['-version']): - raise AtomicParsleyPPError('FFmpeg was not found. Please install.') - - cmd = ['ffmpeg', '-i', filename, '-i', temp_thumbnail, '-c', 'copy', '-map', '0', '-map', '1', '-metadata:s:v', 'title="Album cover"', '-metadata:s:v', 'comment="Cover (Front)"', temp_filename] + options = [ + '-i', temp_thumbnail, '-c', 'copy', '-map', '0', '-map', '1', + '-metadata:s:v', 'title="Album cover"', '-metadata:s:v', 'comment="Cover (Front)"'] self._downloader.to_screen('[ffmpeg] Adding thumbnail to "%s"' % filename) - if self._downloader.params.get('verbose', False): - self._downloader.to_screen('[debug] FFmpeg command line: %s' % shell_quote(cmd)) - - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - stdout, stderr = p.communicate() - - if p.returncode != 0: - msg = stderr.decode('utf-8', 'replace').strip() - raise EmbedThumbnailPPError(msg) + self.run_ffmpeg(filename, temp_filename, options) os.remove(encodeFilename(temp_thumbnail)) os.remove(encodeFilename(filename))