From 4c8cabe8aed2123f9f2f99e3fe209f69a17a7e9b Mon Sep 17 00:00:00 2001 From: MrDoritos Date: Tue, 8 Oct 2019 19:52:03 -0600 Subject: [PATCH] [MKV Thumbnail Support] MKV Thumbnails with FFMpeg --- youtube_dl/postprocessor/embedthumbnail.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/youtube_dl/postprocessor/embedthumbnail.py b/youtube_dl/postprocessor/embedthumbnail.py index 56be914b8..acb7958c9 100644 --- a/youtube_dl/postprocessor/embedthumbnail.py +++ b/youtube_dl/postprocessor/embedthumbnail.py @@ -50,6 +50,19 @@ def run(self, info): 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)) + + if info['ext'] == 'mkv': + options = [ + '-c', 'copy', '-attach', thumbnail_filename, '-metadata:s:t', 'mimetype=image/jpeg'] + + self._downloader.to_screen('[ffmpeg] Adding thumbnail to "%s"' % filename) + + self.run_ffmpeg_multiple_files([filename], temp_filename, options) + if not self._already_have_thumbnail: os.remove(encodeFilename(thumbnail_filename)) os.remove(encodeFilename(filename))