youtube-dl: Thumbnails still not being embedded in (webm/jpg -> mkv) (also seen in closed issue #5840)

vxbinaca@lappy/~$ youtube-dl --verbose --ignore-config --embed-thumbnail https://www.youtube.com/watch?v=QOLi1GvyBHs

[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'--verbose', u'--ignore-config', u'--embed-thumbnail', u'https://www.youtube.com/watch?v=QOLi1GvyBHs']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2015.06.15
[debug] Python version 2.7.9 - Linux-3.19.0-20-generic-x86_64-with-Ubuntu-15.04-vivid
[debug] exe versions: avconv 11.2-6, avprobe 11.2-6
[debug] Proxy map: {}
[youtube] QOLi1GvyBHs: Downloading webpage
[youtube] QOLi1GvyBHs: Extracting video information
[youtube] QOLi1GvyBHs: Downloading DASH manifest
[youtube] QOLi1GvyBHs: Downloading thumbnail ...
[youtube] QOLi1GvyBHs: Writing thumbnail to: HuniePop X Robin-QOLi1GvyBHs.jpg
WARNING: Requested formats are incompatible for merge and will be merged into mkv.
[debug] Invoking downloader on 'https://r3---sn-uhvcpax0n5-hjvl.googlevideo.com/videoplayback?id=40e2e2d46bf2047b&itag=302&source=youtube&requiressl=yes&pcm2cms=yes&pl=23&ms=au&mv=m&mn=sn-uhvcpax0n5-hjvl&mm=31&ratebypass=yes&mime=video/webm&gir=yes&clen=26505944&lmt=1434765936584526&dur=95.612&upn=nBbu_YnbPm4&signature=1245159F65113B8F1434E6BD7353428EB692E169.0126AA038788D8504301719B5F0390FC28FF431C&fexp=9407141,9408142,9408420,9408710,9408856,9412773,9412840,9412988,9413503,9415304,9415635,9416126,9416289,9416456,952640&mt=1434948902&sver=3&key=dg_yt0&ip=172.56.27.126&ipbits=0&expire=1434970568&sparams=ip,ipbits,expire,id,itag,source,requiressl,pcm2cms,pl,ms,mv,mn,mm,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: HuniePop X Robin-QOLi1GvyBHs.f302.webm
[download] 100% of 25.28MiB in 00:14
[debug] Invoking downloader on 'https://r3---sn-uhvcpax0n5-hjvl.googlevideo.com/videoplayback?id=40e2e2d46bf2047b&itag=140&source=youtube&requiressl=yes&pcm2cms=yes&pl=23&ms=au&mv=m&mn=sn-uhvcpax0n5-hjvl&mm=31&ratebypass=yes&mime=audio/mp4&gir=yes&clen=1520780&lmt=1434874413597243&dur=95.712&upn=nBbu_YnbPm4&signature=93DA72014070F112214F1F8F7D7FE42F4CBB6116.877584EAAFD2ABD30BCEA12DF7E9A0A06395A70E&fexp=9407141,9408142,9408420,9408710,9408856,9412773,9412840,9412988,9413503,9415304,9415635,9416126,9416289,9416456,952640&mt=1434948902&sver=3&key=dg_yt0&ip=172.56.27.126&ipbits=0&expire=1434970568&sparams=ip,ipbits,expire,id,itag,source,requiressl,pcm2cms,pl,ms,mv,mn,mm,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: HuniePop X Robin-QOLi1GvyBHs.f140.m4a
[download] 100% of 1.45MiB in 00:01
[ffmpeg] Merging formats into "HuniePop X Robin-QOLi1GvyBHs.mkv"
[debug] ffmpeg command line: avconv -y -i 'HuniePop X Robin-QOLi1GvyBHs.f302.webm' -i 'HuniePop X Robin-QOLi1GvyBHs.f140.m4a' -c copy -map 0:v:0 -map 1:a:0 'HuniePop X Robin-QOLi1GvyBHs.temp.mkv'
Deleting original file HuniePop X Robin-QOLi1GvyBHs.f302.webm (pass -k to keep)
Deleting original file HuniePop X Robin-QOLi1GvyBHs.f140.m4a (pass -k to keep)
ERROR: Only mp3 and m4a/mp4 are supported for thumbnail embedding for now.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 1548, in post_process
    files_to_delete, info = pp.run(info)
  File "/usr/local/lib/python2.7/dist-packages/youtube_dl/postprocessor/embedthumbnail.py", line 85, in run
    raise EmbedThumbnailPPError('Only mp3 and m4a/mp4 are supported for thumbnail embedding for now.')
EmbedThumbnailPPError

About this issue

  • Original URL
  • State: open
  • Created 9 years ago
  • Reactions: 5
  • Comments: 30 (4 by maintainers)

Commits related to this issue

Most upvoted comments

@Nicktheslick69 you should restructure your answer into short readable instructions.

The original pull request should be merged.

If this helps at all, the correct way to add a thumbnail to a MKV container is to add an attachment called either “cover.jpg/png” or “cover_land.jpg/png”. I’m currently adding this to youtube-dl to command FFmpeg to add that attachment: --postprocessor-args "-attach c:/location/of/image/cover.jpg -metadata:s:t mimetype=image/jpeg"

You can find info regarding how thumbnails are used in MKVs here: https://matroska.org/technical/cover_art/index.html Note that while those documents state that the maximum size for a thumbnail’s shortest side is 600 pixels, I attached a 720p image as a thumbnail and I haven’t seen FFmpeg, Icaros or VLC complain. I think the most important part is that the thumbnail be an attachment named correctly.

We have to give up now, use yt-dlp instead which has first class support for muxing into mkv.

$ yt-dlp --embed-thumbnail https://www.youtube.com/watch?v=YGxnaR8JHjI
[youtube] YGxnaR8JHjI: Downloading webpage
[youtube] YGxnaR8JHjI: Downloading android player API JSON
[info] YGxnaR8JHjI: Downloading 1 format(s): 247+251
[info] Downloading video thumbnail 41 ...
[info] Writing video thumbnail 41 to: Surprise sound effect [YGxnaR8JHjI].webp
WARNING: webm doesn't support embedding a thumbnail, mkv will be used
[Metadata] Adding metadata to "Surprise sound effect [YGxnaR8JHjI].mkv"
[EmbedThumbnail] ffmpeg: Adding thumbnail to "Surprise sound effect [YGxnaR8JHjI].mkv"
$ ffprobe Surprise\ sound\ effect\ \[YGxnaR8JHjI\].mkv
...
[matroska,webm @ 0x55f2d4022040] Could not find codec parameters for stream 2 (Attachment: none): unknown codec
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
Input #0, matroska,webm, from 'Surprise sound effect [YGxnaR8JHjI].mkv':
  Metadata:
    title           : Surprise sound effect
    DATE            : 20191222
    DESCRIPTION     : Hi my video is about a sound effect of surprise
    ARTIST          : Meow Gamer
    SYNOPSIS        : Hi my video is about a sound effect of surprise
    PURL            : https://www.youtube.com/watch?v=YGxnaR8JHjI
    COMMENT         : https://www.youtube.com/watch?v=YGxnaR8JHjI
    ENCODER         : Lavf59.16.100
  Duration: 00:00:01.80, start: -0.007000, bitrate: 438 kb/s
  Stream #0:0(eng): Video: vp9 (Profile 0), yuv420p(tv, bt709), 1280x720, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 1k tbn (default)
    Metadata:
      DURATION        : 00:00:01.794000000
  Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 00:00:01.801000000
  Stream #0:2: Attachment: none
    Metadata:
      filename        : cover.webp
      mimetype        : image/webp
Unsupported codec with id 0 for input stream 2

@Nicktheslick69 you should restructure your answer into short readable instructions.

Also please list the right working versions of the McDoritos repo and youtube-dl itself, so if something will eventually change and break, people could lookup for these versions and use them.

@Nicktheslick69 link the right branch because it’s not in his master, it’s in mkvthumbnail.

Hello everyone, initially I turned to the internet to solve this problem and came across this thread detailing how the feature wasn’t implemented yet so I continued to do more digging and eventually found a user named MrDoritos on reddit who created this pull request: #22659

In order to get this working it took some fiddling and communication between the creator but I finally figured it out and forgot about this thread entirely so I will go into as much detail as possible. Another thing I wanted to add before anyone attempts this, I installed vanilla youtube-dl through python so I don’t know where you would find the paths if you installed another way.

                                         Two Steps:
  1. Go to MrDoritos pull request, find: /youtube_dl/postprocessor/embedthumbnail.py and proceed to download “embedthumbnail.py”.

  2. Navigate to ”AppData/Local/Programs/Python/Python37-32/Lib/site-packages/youtube_dl/postprocessor” and replace the old embedthumbnail.py with the MrDoritos version and everything should run flawlessly.

                                         That's All.
    

This works with the latest versions of youtube-dl although if you decide to update youtube-dl when the time comes, you will have to replace embedthumbnail.py in appdata with the doritos variant as mentioned in the steps above.

For those of you who will ask why I didn’t clone the entire repo and install is through python, I couldn’t get it to push changes to the embedthumbnail.py in appdata and installing his entire pull request implies you would be installing everything else along with it that isn’t up to date.

I am so very sorry you guys had to suffer my mobile formatting from before, I have adjusted the links as well. I am also not sure which of the many previous updates to youtube-dl are compatible, I do know that this has worked for me since youtube-dl version 2020.1.1 and has continued to work with the recently released youtube-dl version 2020.03.24

At risk of getting banned, seriously - this issue has been open for years, has a lot of interest (thus the comments looking for help here and the number of related and duplicate bugs) - could we at least know more about the holdup? What is the technical issue blocking this, so that maybe we can help?

Ugh, there is no technical issue. The patch has been seemingly done for almost two years and @dstftw hasn’t reviewed the changes that he himself requested (see #15445 ).

I hope the PR will be requested soon! Can’t wait for this feature

The way I embed thumbnails to mkv was wrong and misleads players like VLC and mpv, so I disable it until the correct approach is implemented…

Much apologies for being late. mkv will be supported for thumbnail embedding in the next version. However, avconv may throw the same error as in #7238. If so, use ffmpeg instead.