aboutsummaryrefslogtreecommitdiffstats
path: root/youtube_dl/postprocessor/embedthumbnail.py
diff options
context:
space:
mode:
authorian <ian@nass>2020-03-20 17:50:50 -0400
committerian <ian@nass>2020-03-20 17:50:50 -0400
commit62566a41b289196d7e9e46498f904e638a033c68 (patch)
tree5d25d20af2f15062727971281f410f054b0c1b31 /youtube_dl/postprocessor/embedthumbnail.py
parent73453430c11002a7193eaa9fb8cf5349fa326c93 (diff)
downloadhypervideo-pre-62566a41b289196d7e9e46498f904e638a033c68.tar.lz
hypervideo-pre-62566a41b289196d7e9e46498f904e638a033c68.tar.xz
hypervideo-pre-62566a41b289196d7e9e46498f904e638a033c68.zip
[MKV Thumbnail Support] Now has the correct file name in MKV container
Diffstat (limited to 'youtube_dl/postprocessor/embedthumbnail.py')
-rw-r--r--youtube_dl/postprocessor/embedthumbnail.py19
1 files changed, 19 insertions, 0 deletions
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.')