From 4c8cabe8aed2123f9f2f99e3fe209f69a17a7e9b Mon Sep 17 00:00:00 2001 From: MrDoritos Date: Tue, 8 Oct 2019 19:52:03 -0600 Subject: [PATCH 1/5] [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 @@ class EmbedThumbnailPP(FFmpegPostProcessor): 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)) From a0b2ee64dbe6d4bedad9883cc8014aa77cdd0138 Mon Sep 17 00:00:00 2001 From: MrDoritos Date: Tue, 8 Oct 2019 20:02:45 -0600 Subject: [PATCH 2/5] [MKV Thumbnail Support] Changed from Tabs to spaces --- youtube_dl/postprocessor/embedthumbnail.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/youtube_dl/postprocessor/embedthumbnail.py b/youtube_dl/postprocessor/embedthumbnail.py index acb7958c9..eae266dde 100644 --- a/youtube_dl/postprocessor/embedthumbnail.py +++ b/youtube_dl/postprocessor/embedthumbnail.py @@ -55,10 +55,10 @@ class EmbedThumbnailPP(FFmpegPostProcessor): 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'] - + 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) From 62566a41b289196d7e9e46498f904e638a033c68 Mon Sep 17 00:00:00 2001 From: ian Date: Fri, 20 Mar 2020 17:50:50 -0400 Subject: [PATCH 3/5] [MKV Thumbnail Support] Now has the correct file name in MKV container --- youtube_dl/postprocessor/embedthumbnail.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/youtube_dl/postprocessor/embedthumbnail.py b/youtube_dl/postprocessor/embedthumbnail.py index 56be914b8..4393c4e7a 100644 --- a/youtube_dl/postprocessor/embedthumbnail.py +++ b/youtube_dl/postprocessor/embedthumbnail.py @@ -55,6 +55,25 @@ class EmbedThumbnailPP(FFmpegPostProcessor): os.remove(encodeFilename(filename)) os.rename(encodeFilename(temp_filename), encodeFilename(filename)) + elif info['ext'] == 'mkv': + os.rename(encodeFilename(thumbnail_filename), encodeFilename('cover.jpg')) + old_thumbnail_filename = thumbnail_filename + thumbnail_filename = 'cover.jpg' + + 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)) + else: + os.rename(encodeFilename(thumbnail_filename), encodeFilename(old_thumbnail_filename)) + os.remove(encodeFilename(filename)) + os.rename(encodeFilename(temp_filename), encodeFilename(filename)) + elif info['ext'] in ['m4a', 'mp4']: if not check_executable('AtomicParsley', ['-v']): raise EmbedThumbnailPPError('AtomicParsley was not found. Please install.') From 50d8b605290be2b7522e4b262a5822bdb753d994 Mon Sep 17 00:00:00 2001 From: MrDoritos Date: Fri, 20 Mar 2020 18:06:42 -0400 Subject: [PATCH 4/5] [MKV Thumbnail Support] Now has the correct file name in MKV container --- youtube_dl/postprocessor/embedthumbnail.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/youtube_dl/postprocessor/embedthumbnail.py b/youtube_dl/postprocessor/embedthumbnail.py index 795582259..4393c4e7a 100644 --- a/youtube_dl/postprocessor/embedthumbnail.py +++ b/youtube_dl/postprocessor/embedthumbnail.py @@ -55,15 +55,11 @@ class EmbedThumbnailPP(FFmpegPostProcessor): os.remove(encodeFilename(filename)) os.rename(encodeFilename(temp_filename), encodeFilename(filename)) -<<<<<<< HEAD elif info['ext'] == 'mkv': os.rename(encodeFilename(thumbnail_filename), encodeFilename('cover.jpg')) old_thumbnail_filename = thumbnail_filename thumbnail_filename = 'cover.jpg' -======= - if info['ext'] == 'mkv': ->>>>>>> a0b2ee64dbe6d4bedad9883cc8014aa77cdd0138 options = [ '-c', 'copy', '-attach', thumbnail_filename, '-metadata:s:t', 'mimetype=image/jpeg'] @@ -73,11 +69,8 @@ class EmbedThumbnailPP(FFmpegPostProcessor): if not self._already_have_thumbnail: os.remove(encodeFilename(thumbnail_filename)) -<<<<<<< HEAD else: os.rename(encodeFilename(thumbnail_filename), encodeFilename(old_thumbnail_filename)) -======= ->>>>>>> a0b2ee64dbe6d4bedad9883cc8014aa77cdd0138 os.remove(encodeFilename(filename)) os.rename(encodeFilename(temp_filename), encodeFilename(filename)) From 25925fd759e2940a0dbc065554f96cdf805a4a01 Mon Sep 17 00:00:00 2001 From: MrDoritos Date: Sun, 22 Nov 2020 21:10:03 -0500 Subject: [PATCH 5/5] Add WEBM to supported containers --- youtube_dl/postprocessor/embedthumbnail.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/postprocessor/embedthumbnail.py b/youtube_dl/postprocessor/embedthumbnail.py index 4a0d02fc4..a80b145dd 100644 --- a/youtube_dl/postprocessor/embedthumbnail.py +++ b/youtube_dl/postprocessor/embedthumbnail.py @@ -88,7 +88,7 @@ class EmbedThumbnailPP(FFmpegPostProcessor): os.remove(encodeFilename(filename)) os.rename(encodeFilename(temp_filename), encodeFilename(filename)) - elif info['ext'] == 'mkv': + elif info['ext'] in ['mkv', 'webm']: os.rename(encodeFilename(thumbnail_filename), encodeFilename('cover.jpg')) old_thumbnail_filename = thumbnail_filename thumbnail_filename = 'cover.jpg'