youtube-dl icon indicating copy to clipboard operation
youtube-dl copied to clipboard

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

Open vxbinaca opened this issue 9 years ago • 30 comments

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

vxbinaca avatar Jun 22 '15 05:06 vxbinaca

@pulpe Seems the ffmpeg approach in EmbedThumbnailPP works for mkv format, too. Would you like to add mkv to allowed extensions?

yan12125 avatar Jul 02 '15 09:07 yan12125

@yan12125 if someone were to specify avconv as an encoder wouldn't this bug creep back up?

vxbinaca avatar Jul 02 '15 16:07 vxbinaca

Thanks for reminding. I've just tested against ffmpeg 2.5.7 and avconv 11.2 on ubuntu 15.04, and both works. Something weird is that avconv adds the image twice:

Input #0, matroska,webm, from 'HuniePop X Robin-QOLi1GvyBHs.mkv':
  Metadata:
    ENCODER         : Lavf56.1.0
  Duration: 00:01:35.71, start: 0.000000, bitrate: N/A
    Stream #0.0(eng): Video: vp9, yuv420p, 1280x720, PAR 1:1 DAR 16:9, 60.61 fps, 1k tbn (default)
    Metadata:
      title           : "Album cover"
      LANGUAGE        : eng
      COMMENT         : "Cover (Front)"
    Stream #0.1(und): Audio: aac, 44100 Hz, stereo, fltp (default)
    Metadata:
      CREATION_TIME   : 2015-06-21 08:13:15
      LANGUAGE        : und
      HANDLER_NAME    : SoundHandler
    Stream #0.2: Video: mjpeg, yuvj420p, 480x360 [PAR 1:1 DAR 4:3], 1k tbn
    Metadata:
      title           : "Album cover"
      COMMENT         : "Cover (Front)"
    Stream #0.3: Video: mjpeg, yuvj420p, 480x360 [PAR 1:1 DAR 4:3], 1k tbn
    Metadata:
      title           : "Album cover"
      COMMENT         : "Cover (Front)"
# avprobe output

yan12125 avatar Jul 03 '15 04:07 yan12125

Should I report this to avconv and keep you abreast of the status of the bug?

vxbinaca avatar Jul 03 '15 04:07 vxbinaca

That would be fine. Not sure whether avconv needs different arguments than ffmpeg's. If this is the case, things are easy, otherwise we have to check avconv's version in EmbedThumbnailPP.

yan12125 avatar Jul 03 '15 10:07 yan12125

@yan12125 rule out the problem being on youtube-dl's end, and I'll file the report. Change the args if need be.

vxbinaca avatar Jul 03 '15 10:07 vxbinaca

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.

yan12125 avatar Feb 20 '16 19:02 yan12125

Thanks I'll update my config to force ffmpeg use.

vxbinaca avatar Feb 20 '16 21:02 vxbinaca

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..

yan12125 avatar Oct 20 '16 07:10 yan12125

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.

XJDHDR avatar Feb 15 '17 03:02 XJDHDR

Any update on this?

superpoincare avatar Sep 12 '17 12:09 superpoincare

@yan12125 any updates on this?

Dialga avatar Nov 04 '18 17:11 Dialga

We are still waiting for this.

Barafu avatar Feb 08 '19 16:02 Barafu

Would love this to be fixed.

aksh1618 avatar Mar 10 '19 22:03 aksh1618

Any updates?

pqhf5kd avatar Dec 19 '19 10:12 pqhf5kd

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 ).

diamondsw avatar Mar 08 '20 16:03 diamondsw

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

ilovelinux avatar Apr 06 '20 18:04 ilovelinux

Guys, I think you really ought to add this feature, this issue is opened more than 5 years along

nt4f04uNd avatar Apr 27 '20 23:04 nt4f04uNd

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

N72826 avatar Apr 28 '20 05:04 N72826

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

Dialga avatar Apr 28 '20 07:04 Dialga

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

Thanks, I don't know how I looked past that the first time. I will be sure to update my original reply.

N72826 avatar Apr 28 '20 07:04 N72826

@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.

nt4f04uNd avatar Apr 28 '20 09:04 nt4f04uNd

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

The original pull request should be merged.

diamondsw avatar May 04 '20 03:05 diamondsw

Any update on whats stopping the pull request from being merged? Need more testing or something?

SamuelKurtzer avatar Jun 29 '20 03:06 SamuelKurtzer

+1

zxHreQK avatar Jun 30 '20 18:06 zxHreQK

+1

irateadmin avatar Sep 09 '20 17:09 irateadmin

I don't think I mentioned this before since I had everything running smoothly on windows 10.

I recently tried running my youtube-dl configuration on my raspberry pi and after a lengthy troubleshooting process of auto mounting my network drives and getting used to the linux filesystem, the thumbnails weren't embedding even with the most recent version of dorito's embedthumbnail.py

My frustration grew until I decided to look inside the python file and saw that his modification calls AtomicParsley to embed the thumbnail, I installed it through apt and it worked.

Now my only issue is figuring out the best way to schedule the script to run on an interval akin to the task scheduler in windows. That's my problem though and I just wanted to inform anyone who tried this out unsuccessfully to install AtomicParsley and see if that is the issue.

If anyone is native to linux and schedules youtube-dl a better way than cron I would love to know how. Thank you

N72826 avatar Sep 09 '20 17:09 N72826

+1

WoodpeckerBaby avatar Jan 10 '21 16:01 WoodpeckerBaby

+1

WoodpeckerBaby avatar Aug 04 '22 14:08 WoodpeckerBaby

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

Dialga avatar Aug 04 '22 14:08 Dialga