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.28k stars 10.03k forks source link

YouTube format 22 is missing for some videos #30442

Closed kclauhk closed 2 years ago

kclauhk commented 2 years ago

Format 22 (mp4 1280x720 avc1.64001F, mp4a.40.2) of some YouTube videos cannot be downloaded or listed by -F option. Example: https://www.youtube.com/watch?v=jgpJVI3tDbY https://www.youtube.com/watch?v=DOBjwlfIZdE

dirkf commented 2 years ago

Might that be because that format is not being distributed by YT for those videos?

yt-dl just plays back what YT tells it regarding the available formats..

kclauhk commented 2 years ago

The 2 examples have the format 22 except 22, format 139 (audio only, mp4a.40.5) is missing as well

nicolaasjan commented 2 years ago

FWIW, with the youtube-dl fork yt-dlp, both videos can be downloaded in format 22. The first:

yt-dlp -v -f 22 https://www.youtube.com/watch?v=jgpJVI3tDbY
[debug] Command-line config: ['-v', '-f', '22', 'https://www.youtube.com/watch?v=jgpJVI3tDbY']
[debug] User config file: /home/nico/.config/yt-dlp/config
[debug] User config: ['-o', '/dev/shm/test-dlp/%(title)s.%(ext)s', '-f', 'bestvideo[height<=1080][ext=mp4][vcodec!*=av01]+bestaudio[ext=m4a]/best[ext=mp4]/best', '--no-mtime', '--add-metadata', '--convert-thumbnails', 'jpg', '--embed-thumbnail', '--ppa', 'ThumbnailsConvertor:-q:v 1', '--ppa', 'ffmpeg:-metadata synopsis=""', '--force-ipv4', '--sponsorblock-remove', 'all', '--console-title', '--cookies-from-browser', 'firefox', '--downloader', 'aria2c', '--downloader-args', 'aria2c:-x 10 -s 10 -j 10 -k 1M --log-level=info --file-allocation=none']
[Cookies] Extracting cookies from firefox
[debug] Extracting cookies from: "/home/nico/.mozilla/firefox/ivy4ozwp.default-release-1/cookies.sqlite"
[Cookies] Extracted 167 cookies from firefox
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, err UTF-8, pref UTF-8
[debug] yt-dlp version 2021.12.29 [6223f67a8] (zip)
[debug] Python version 3.6.9 (CPython 64bit) - Linux-5.4.0-91-generic-x86_64-with-LinuxMint-19.3-tricia
[debug] exe versions: ffmpeg N-104865-g571e8ca2dd-Nico-20211216-with-non-monotonous-DTS-Fix (fdk,setts), ffprobe N-104865-g571e8ca2dd-Nico-20211216-with-non-monotonous-DTS-Fix, phantomjs 2.1.1
[debug] Optional libraries: Cryptodome, secretstorage, mutagen, sqlite, websockets
[debug] Proxy map: {}
[debug] [youtube] Extracting URL: https://www.youtube.com/watch?v=jgpJVI3tDbY
[youtube] jgpJVI3tDbY: Downloading webpage
[youtube] jgpJVI3tDbY: Downloading android player API JSON
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, codec:vp9.2, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, vcodec:vp9.2(10), acodec, lang, proto, filesize, fs_approx, tbr, vbr, abr, asr, vext, aext, hasaud, id
[SponsorBlock] Fetching SponsorBlock segments
[debug] SponsorBlock query: https://sponsor.ajay.app/api/skipSegments/74a2?service=YouTube&categories=%5B%22outro%22%2C+%22intro%22%2C+%22filler%22%2C+%22interaction%22%2C+%22selfpromo%22%2C+%22preview%22%2C+%22music_offtopic%22%2C+%22sponsor%22%5D
[SponsorBlock] No segments were found in the SponsorBlock database
[info] jgpJVI3tDbY: Downloading 1 format(s): 22
[info] Downloading video thumbnail 41 ...
[info] Writing video thumbnail 41 to: /dev/shm/test-dlp/The Best of Classical Music 🎻 Mozart, Beethoven, Bach, Chopin, Vivaldi 🎹 Most Famous Classic Pieces.webp
[ThumbnailsConvertor] Converting thumbnail "/dev/shm/test-dlp/The Best of Classical Music 🎻 Mozart, Beethoven, Bach, Chopin, Vivaldi 🎹 Most Famous Classic Pieces.webp" to jpg
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -f image2 -pattern_type none -i 'file:/dev/shm/test-dlp/The Best of Classical Music 🎻 Mozart, Beethoven, Bach, Chopin, Vivaldi 🎹 Most Famous Classic Pieces.webp' -bsf:v mjpeg2jpeg -movflags +faststart -q:v 1 -metadata synopsis= 'file:/dev/shm/test-dlp/The Best of Classical Music 🎻 Mozart, Beethoven, Bach, Chopin, Vivaldi 🎹 Most Famous Classic Pieces.jpg'
Deleting original file /dev/shm/test-dlp/The Best of Classical Music 🎻 Mozart, Beethoven, Bach, Chopin, Vivaldi 🎹 Most Famous Classic Pieces.webp (pass -k to keep)
[debug] Invoking downloader on "https://rr2---sn-5hne6nsk.googlevideo.com/videoplayback?expire=1640807509&ei=9WfMYabHEIHJ1wLugL7QBQ&ip=<REDACTED>&id=o-ALfaBc8AZad4pfqhM2kJ2aMP_i4detrv1FPOcr_e18ig&itag=22&source=youtube&requiressl=yes&mh=uJ&mm=31%2C29&mn=sn-5hne6nsk%2Csn-5hnekn7z&ms=au%2Crdu&mv=m&mvi=2&pl=19&initcwndbps=2200000&vprv=1&mime=video%2Fmp4&ratebypass=yes&dur=12499.371&lmt=1628984091657916&mt=1640785521&fvip=2&fexp=24001373%2C24007246&c=ANDROID&txp=5532434&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIhAP5HHcdqxrqO1YmuNEGkVLM45BpMSLhWRpfLpnXpS01tAiBMxxGUNADsZvHm4VI_ZBBcGTMQppKiAtmELvJ8Aj8kkQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgM93lwzPzkvsq6FxAgzRmfghuXvkFvfZ0mAWqGfnQ_o8CIG3hqzzxqLBJpicGeL_pkB_kuiWDQ2IpxdLDDD99clMi"
[download] Destination: /dev/shm/test-dlp/The Best of Classical Music 🎻 Mozart, Beethoven, Bach, Chopin, Vivaldi 🎹 Most Famous Classic Pieces.mp4
[debug] aria2c command line: aria2c -c --console-log-level=warn --summary-interval=0 --download-result=hide --file-allocation=none -x16 -j16 -s16 --min-split-size 1M --header 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36' --header 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' --header 'Accept-Encoding: gzip, deflate' --header 'Accept-Language: en-us,en;q=0.5' --interface 0.0.0.0 --check-certificate=true --remote-time=false --show-console-readout=true -x 10 -s 10 -j 10 -k 1M --log-level=info --file-allocation=none --dir /dev/shm/test-dlp/ --out './The Best of Classical Music 🎻 Mozart, Beethoven, Bach, Chopin, Vivaldi 🎹 Most Famous Classic Pieces.mp4.part' --auto-file-renaming=false -- 'https://rr2---sn-5hne6nsk.googlevideo.com/videoplayback?expire=1640807509&ei=9WfMYabHEIHJ1wLugL7QBQ&ip=<REDACTED>&id=o-ALfaBc8AZad4pfqhM2kJ2aMP_i4detrv1FPOcr_e18ig&itag=22&source=youtube&requiressl=yes&mh=uJ&mm=31%2C29&mn=sn-5hne6nsk%2Csn-5hnekn7z&ms=au%2Crdu&mv=m&mvi=2&pl=19&initcwndbps=2200000&vprv=1&mime=video%2Fmp4&ratebypass=yes&dur=12499.371&lmt=1628984091657916&mt=1640785521&fvip=2&fexp=24001373%2C24007246&c=ANDROID&txp=5532434&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIhAP5HHcdqxrqO1YmuNEGkVLM45BpMSLhWRpfLpnXpS01tAiBMxxGUNADsZvHm4VI_ZBBcGTMQppKiAtmELvJ8Aj8kkQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgM93lwzPzkvsq6FxAgzRmfghuXvkFvfZ0mAWqGfnQ_o8CIG3hqzzxqLBJpicGeL_pkB_kuiWDQ2IpxdLDDD99clMi'
[#5c8ca1 204MiB/2.1GiB(9%) CN:10 DL:9.0MiB ETA:3m43s]^C                        
ERROR: Interrupted by user

Formats:

sb2 mhtml 48x27          │                  mhtml │ images                                      storyboard
sb1 mhtml 80x45          │                  mhtml │ images                                      storyboard
sb0 mhtml 160x90         │                  mhtml │ images                                      storyboard
139 m4a                  │   72.69MiB   48k https │ audio only          mp4a.40.5   48k 22050Hz low, m4a_dash
249 webm                 │   80.84MiB   54k https │ audio only          opus        54k 48000Hz low, webm_dash
250 webm                 │  107.45MiB   72k https │ audio only          opus        72k 48000Hz low, webm_dash
140 m4a                  │  192.92MiB  129k https │ audio only          mp4a.40.2  129k 44100Hz medium, m4a_dash
251 webm                 │  207.76MiB  139k https │ audio only          opus       139k 48000Hz medium, webm_dash
17  3gp   176x144      7 │  103.86MiB   69k https │ mp4v.20.3       69k mp4a.40.2    0k 22050Hz 144p
394 mp4   256x144     30 │   78.29MiB   52k https │ av01.0.00M.08   52k video only              144p, mp4_dash
160 mp4   256x144     30 │   46.80MiB   31k https │ avc1.4d400c     31k video only              144p, mp4_dash
278 webm  256x144     30 │   83.95MiB   56k https │ vp9             56k video only              144p, webm_dash
395 mp4   426x240     30 │  107.74MiB   72k https │ av01.0.00M.08   72k video only              240p, mp4_dash
133 mp4   426x240     30 │   95.68MiB   64k https │ avc1.4d4015     64k video only              240p, mp4_dash
242 webm  426x240     30 │   98.45MiB   66k https │ vp9             66k video only              240p, webm_dash
396 mp4   640x360     30 │  202.25MiB  135k https │ av01.0.01M.08  135k video only              360p, mp4_dash
134 mp4   640x360     30 │  178.67MiB  119k https │ avc1.4d401e    119k video only              360p, mp4_dash
18  mp4   640x360     30 │  723.92MiB  485k https │ avc1.42001E    485k mp4a.40.2    0k 44100Hz 360p
243 webm  640x360     30 │  163.78MiB  109k https │ vp9            109k video only              360p, webm_dash
397 mp4   854x480     30 │  381.11MiB  255k https │ av01.0.04M.08  255k video only              480p, mp4_dash
135 mp4   854x480     30 │  269.74MiB  181k https │ avc1.4d401f    181k video only              480p, mp4_dash
244 webm  854x480     30 │  240.71MiB  161k https │ vp9            161k video only              480p, webm_dash
398 mp4   1280x720    30 │  920.79MiB  617k https │ av01.0.05M.08  617k video only              720p, mp4_dash
136 mp4   1280x720    30 │  425.05MiB  285k https │ avc1.4d401f    285k video only              720p, mp4_dash
22  mp4   1280x720    30 │ ~  2.22GiB 1489k https │ avc1.64001F   1489k mp4a.40.2    0k 44100Hz 720p
247 webm  1280x720    30 │  451.89MiB  303k https │ vp9            303k video only              720p, webm_dash
dirkf commented 2 years ago

So this is probably a function of the client data presented to YT. Perhaps this patch can be adapted to offer the desired formats. I see that it listed formats 22 and 139 for the test video in that issue. See https://github.com/ytdl-org/youtube-dl/issues/30117#issuecomment-1002660512.

ghost commented 2 years ago

Duplicate of #30117.

dirkf commented 2 years ago

I have an alternate tool that works:

That's nice.

dirkf commented 2 years ago

Format 22 is now being found by current HEAD, but that may just reflect a site change.