ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
132.73k stars 10.07k forks source link

Option --embed-thumbnail does not work with avconv #26702

Open florianpasteur opened 4 years ago

florianpasteur commented 4 years ago

Checklist

Verbose log

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', '--embed-thumbnail', '--extract-audio', '--audio-format', 'mp3', 'https://music.youtube.com/watch?v=P2IxGppZhxo']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2020.09.20
[debug] Python version 3.7.2 (CPython) - Darwin-19.6.0-x86_64-i386-64bit
[debug] exe versions: avconv 12.3, avprobe 12.3, ffprobe 4.3.1, rtmpdump 2.4
[debug] Proxy map: {}
[youtube] P2IxGppZhxo: Downloading webpage
[youtube] {18} signature length 107, html5 player 12237e3d
[youtube] {137} signature length 107, html5 player 12237e3d
[youtube] {248} signature length 107, html5 player 12237e3d
[youtube] {136} signature length 107, html5 player 12237e3d
[youtube] {247} signature length 107, html5 player 12237e3d
[youtube] {135} signature length 107, html5 player 12237e3d
[youtube] {244} signature length 107, html5 player 12237e3d
[youtube] {134} signature length 107, html5 player 12237e3d
[youtube] {243} signature length 107, html5 player 12237e3d
[youtube] {133} signature length 107, html5 player 12237e3d
[youtube] {242} signature length 107, html5 player 12237e3d
[youtube] {160} signature length 103, html5 player 12237e3d
[youtube] {278} signature length 107, html5 player 12237e3d
[youtube] {394} signature length 107, html5 player 12237e3d
[youtube] {140} signature length 107, html5 player 12237e3d
[youtube] {249} signature length 107, html5 player 12237e3d
[youtube] {250} signature length 103, html5 player 12237e3d
[youtube] {251} signature length 107, html5 player 12237e3d
[youtube] P2IxGppZhxo: Downloading thumbnail ...
[youtube] P2IxGppZhxo: Writing thumbnail to: Ne me ramène pas-P2IxGppZhxo.webp
[debug] Invoking downloader on 'https://r3---sn-5hnekn7l.googlevideo.com/videoplayback?expire=1601035490&ei=gYhtX4z2OZeigQfY2L3IDA&ip=213.127.113.242&id=o-AAeB6kvxP_ARQzsG9C3_zNF0JmKmUqVSg94jBwRzVp0P&itag=251&source=youtube&requiressl=yes&mh=-A&mm=31%2C29&mn=sn-5hnekn7l%2Csn-5hne6nsd&ms=au%2Crdu&mv=m&mvi=3&pl=17&gcr=nl&initcwndbps=2360000&vprv=1&mime=audio%2Fwebm&gir=yes&clen=2502930&dur=136.521&lmt=1577217924607483&mt=1601013760&fvip=3&keepalive=yes&fexp=23915654&c=WEB&txp=5531432&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cgcr%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhAJrJq6BUQDNQR6nY3A6-sAP_6Df58VJTUeFKjsHJ_mGXAiEA1YI5BHW130c9QAyFPXwB61-1_xTHcbPGe1nPLrk_rlw%3D&sig=AOq0QJ8wRQIhAJle5b8VVH5Pg28CVwAL-rsJPVS2HEaudmZpqybKYP6WAiBrxr_7zReCOhlkPWgHrKxcWmYdqeotetIRTEn7u3PveQ==&ratebypass=yes'
[download] Destination: Ne me ramène pas-P2IxGppZhxo.webm
[download] 100% of 2.39MiB in 00:00
[debug] avconv command line: ffprobe -show_streams 'file:Ne me ramène pas-P2IxGppZhxo.webm'
[ffmpeg] Destination: Ne me ramène pas-P2IxGppZhxo.mp3
[debug] ffmpeg command line: avconv -y -i 'file:Ne me ramène pas-P2IxGppZhxo.webm' -vn -acodec libmp3lame -q:a 5 'file:Ne me ramène pas-P2IxGppZhxo.mp3'
Deleting original file Ne me ramène pas-P2IxGppZhxo.webm (pass -k to keep)
[ffmpeg] Converting thumbnail "Ne me ramène pas-P2IxGppZhxo.webp" to JPEG
[debug] ffmpeg command line: avconv -y -i 'file:Ne me ramène pas-P2IxGppZhxo.webp' -bsf:v mjpeg2jpeg 'file:Ne me ramène pas-P2IxGppZhxo.jpg'
ERROR: Error applying bitstream filters to an output packet for stream #0:0.
Traceback (most recent call last):
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 2065, in post_process
    files_to_delete, info = pp.run(info)
  File "/usr/local/bin/youtube-dl/youtube_dl/postprocessor/embedthumbnail.py", line 70, in run
    self.run_ffmpeg(escaped_thumbnail_filename, escaped_thumbnail_jpg_filename, ['-bsf:v', 'mjpeg2jpeg'])
  File "/usr/local/bin/youtube-dl/youtube_dl/postprocessor/ffmpeg.py", line 239, in run_ffmpeg
    self.run_ffmpeg_multiple_files([path], out_path, opts)
  File "/usr/local/bin/youtube-dl/youtube_dl/postprocessor/ffmpeg.py", line 235, in run_ffmpeg_multiple_files
    raise FFmpegPostProcessorError(msg)
youtube_dl.postprocessor.ffmpeg.FFmpegPostProcessorError: Error applying bitstream filters to an output packet for stream #0:0.

Description

Hello,

When I use the option --embed-thumbnail the download fails because of converting the thumbnail to jpg image. Actually the error comes from the command: avconv -y -i 'file:Ne me ramène pas-P2IxGppZhxo.webp' -bsf:v mjpeg2jpeg 'file:Ne me ramène pas-P2IxGppZhxo.jpg', apparently avconv is not able to convert webp images to jpg. I couldn't find a way to to do it in the manual of avconv

Here the dependencies version:

$ avconv -L
avconv version 12.3, Copyright (c) 2000-2018 the Libav developers
  built on Jul  3 2020 19:38:15 with Apple clang version 11.0.3 (clang-1103.0.32.62)
This version of avconv has nonfree parts compiled in.
Therefore it is not legally redistributable.

No ffmpeg installed.

Workaroung

As workaround, I installed ffmpeg and the command succeed.

Possible solutions

Instead of using avconv to convert the image maybe an explicit error can be thrown to invite installing ffmpeg or maybe youtube-dl can try to download a lower resolution jpg image.

ghost commented 3 years ago

I think this is simply a libav/avconv bug, by not porting ffmpeg fixes. I've searched the source codes from the error input is not MJPEG/AVI1 when I ran avconv manually.

libav: https://github.com/libav/libav/blob/c4642788e83b0858bca449f9b6e71ddb015dfa5d/libavcodec/mjpeg2jpeg_bsf.c#L88-L104

ffmpeg: https://github.com/FFmpeg/FFmpeg/blob/dc91b913b6260e85e1304c74ff7bb3c22a8c9fb1/libavcodec/mjpeg2jpeg_bsf.c#L91-L110

libav seems to miss this fix specifically: https://github.com/FFmpeg/FFmpeg/commit/d3fe2e0dc991720bab723e6bc467976e0b14709a#diff-e249fd2ae0deb110c8165a3711a700c09b2e514aa57748d3ac1453d4a2414ddf