diff options
Diffstat (limited to 'youtube_dl/postprocessor')
-rw-r--r-- | youtube_dl/postprocessor/__init__.py | 2 | ||||
-rw-r--r-- | youtube_dl/postprocessor/ffmpeg.py | 23 |
2 files changed, 25 insertions, 0 deletions
diff --git a/youtube_dl/postprocessor/__init__.py b/youtube_dl/postprocessor/__init__.py index 7f505b58e..f8507951c 100644 --- a/youtube_dl/postprocessor/__init__.py +++ b/youtube_dl/postprocessor/__init__.py @@ -6,6 +6,7 @@ from .ffmpeg import ( FFmpegAudioFixPP, FFmpegEmbedSubtitlePP, FFmpegExtractAudioPP, + FFmpegFixupStretchedPP, FFmpegMergerPP, FFmpegMetadataPP, FFmpegVideoConvertorPP, @@ -24,6 +25,7 @@ __all__ = [ 'FFmpegAudioFixPP', 'FFmpegEmbedSubtitlePP', 'FFmpegExtractAudioPP', + 'FFmpegFixupStretchedPP', 'FFmpegMergerPP', 'FFmpegMetadataPP', 'FFmpegPostProcessor', diff --git a/youtube_dl/postprocessor/ffmpeg.py b/youtube_dl/postprocessor/ffmpeg.py index d1b342c7a..6e9194fa6 100644 --- a/youtube_dl/postprocessor/ffmpeg.py +++ b/youtube_dl/postprocessor/ffmpeg.py @@ -51,6 +51,10 @@ class FFmpegPostProcessor(PostProcessor): return dict((p, get_exe_version(p, args=['-version'])) for p in programs) @property + def available(self): + return self._executable is not None + + @property def _executable(self): if self._downloader.params.get('prefer_ffmpeg', False): prefs = ('ffmpeg', 'avconv') @@ -540,3 +544,22 @@ class FFmpegAudioFixPP(FFmpegPostProcessor): os.rename(encodeFilename(temp_filename), encodeFilename(filename)) return True, info + + +class FFmpegFixupStretchedPP(FFmpegPostProcessor): + def run(self, info): + stretched_ratio = info.get('stretched_ratio') + if stretched_ratio is None or stretched_ratio == 1: + return + + filename = info['filepath'] + temp_filename = prepend_extension(filename, 'temp') + + options = ['-c', 'copy', '-aspect', '%f' % stretched_ratio] + self._downloader.to_screen('[ffmpeg] Fixing aspect ratio in "%s"' % filename) + self.run_ffmpeg(filename, temp_filename, options) + + os.remove(encodeFilename(filename)) + os.rename(encodeFilename(temp_filename), encodeFilename(filename)) + + return True, info |