Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YouTube] Initial implementation of clips #30850

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dirkf
Copy link
Contributor

@dirkf dirkf commented Apr 12, 2022

Boilerplate: own code, improvement ## Please follow the guide below
  • You will be asked some questions, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your pull request (like that [x])
  • Use Preview tab to see how your pull request will actually look like

Before submitting a pull request make sure you have:

In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:

  • I am the original author of this code and I am willing to release it under Unlicense
  • I am not the original author of this code but it is in public domain or released under Unlicense (provide reliable evidence)

What is the purpose of your pull request?

  • Bug fix
  • Improvement
  • New extractor
  • New feature

Description of your pull request and other information

From issue #30843 (also yt-dlp/yt-dlp#2543), YT is now supporting clips, which have a URL path like /clip/{opaque_encoding_string}. See also https://support.google.com/youtube/answer/10332730?hl=en.

In yt-dl such a URL is silently extracted as the whole video from which the clip was taken; in yt-dlp the clip is identified as unsupported.

This PR implements a simple-minded solution to extracting the clip by finding the start and end times, passing them as a hidden parameter, enforcing the FFmpegFD downloader when that parameter is present, and prepending the ffmpeg -ss ... and -to ... options with the passed values to the downloader options.

To do

  • Confirm for separate video+audio streams
  • Should the ID, title or other metadata be modified from that of the original video to distinguish the clip from the original? (NB _url_transparent doesn't override the ID, but maybe pass to subclass YoutubeClipIE of YoutubeIE)
  • Similarly what about --download-archive?
  • Add formal tests
  • Should there be a framework for this to support other sites?
  • The clipping details should be recorded in the info_dict and unpacked from it so that --load-info-json ... works.

Resolves #30843.

Comment on lines +67 to +69
if params.get('_clip_args'):
return FFmpegFD

Copy link
Contributor

@pukkandan pukkandan Apr 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should test this on DASH formats. I don't remember exactly what the issue was, but I remember FfmpegFD not working well with them

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So with

140          m4a        audio only tiny  129k , m4a_dash container, mp4a.40.2@129k (44100Hz), 60.45MiB
...
133          mp4        426x240    240p   59k , mp4_dash container, avc1.4d4015@  59k, 24fps, video only, 27.58MiB

this:

$ python -m youtube_dl -v -f 133+140 'https://www.youtube.com/clip/Ugkxp20Fu4TVKSZyQn1u3_fi8HNeQTrgfwrO'
[debug] System config: [u'--prefer-ffmpeg']
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-v', u'-f', u'133+140', u'https://www.youtube.com/clip/Ugkxp20Fu4TVKSZyQn1u3_fi8HNeQTrgfwrO']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2021.12.17
[debug] Git HEAD: f70619bfe
[debug] Python version 2.7.17 (CPython) - Linux-4.4.0-210-generic-i686-with-Ubuntu-16.04-xenial
[debug] exe versions: avconv 4.3, avprobe 4.3, ffmpeg 4.3, ffprobe 4.3
[debug] Proxy map: {}
[youtube:tab] clip: Downloading webpage
[youtube] z_czmz_bJqk: Downloading webpage
[debug] [youtube] Decrypted nsig L717rv5XFsWA2lHQ => 9Y784q6IR9v-dA
[debug] [youtube] Decrypted nsig LRvLyqvSu070BVKw => hlBOLUzpYFaqKQ
[debug] Invoking downloader on u'https://rr3---sn-cu-aigss.googlevideo.com/videoplayback?sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cspc%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&fexp=24001373%2C24007246&ei=471WYoT1LKeLp-oP2eWXyAI&ip=51.6.89.181&clen=28918839&spc=4ocVC0yf2WoJFasH7_ir2yAn_Yw0&id=o-AAm9l9mlTSo_DhyH8CWtsKfv9nfpuFUR4OjEEKVlSKBR&txp=5535432&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278%2C394%2C395%2C396%2C397%2C398%2C399&gir=yes&requiressl=yes&keepalive=yes&source=youtube&sig=AOq0QJ8wRgIhAIxg1jjltOI1_-2V1ypibhS-3An6HLpLT_Jgl6At5vC4AiEA2zvtSTwPOTsVFQhlXkDwJMJ1KYgjNHLkGsbbda_Ry6E%3D&dur=3916.412&ns=O7E7EL9bhdVeypKUULyDRwoG&initcwndbps=1343750&vprv=1&lsig=AG3C_xAwRQIgT7d0Gcuw_wnk0X-GtUD8IWDwQgkOYDW2EJLyDQQLd8UCIQDebjtDb-MqcDT1WHtGEmdYpaC7BeuQrj5nQsQqC0mcDQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lmt=1646365305229507&c=WEB&expire=1649873475&mime=video%2Fmp4&fvip=7&itag=133&mm=31%2C29&mn=sn-cu-aigss%2Csn-cu-c9is&mh=L2&n=9Y784q6IR9v-dA&mt=1649851510&mv=m&pl=25&ms=au%2Crdu&mvi=3'
[download] Destination: How Ludwig Became The Biggest Twitch Streamer…Then Left For Youtube-z_czmz_bJqk.f133.mp4
[debug] ffmpeg command line: ffmpeg -y -loglevel verbose -headers 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.90 Safari/537.36
' -ss 947673ms -to 986799ms -i 'https://rr3---sn-cu-aigss.googlevideo.com/videoplayback?[... as above ...]' -c copy -f mp4 'file:How Ludwig Became The Biggest Twitch Streamer…Then Left For Youtube-z_czmz_bJqk.f133.mp4.part'
ffmpeg version 4.3-2ubuntu0~ppa16.04+8 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) 20160609
  ...
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
[tcp @ 0x1c82680] Starting connection attempt to 86.189.112.78 port 443
[tcp @ 0x1c82680] Successfully connected to 86.189.112.78 port 443
[h264 @ 0x1ec7080] Reinit context to 432x240, pix_fmt: yuv420p
[tcp @ 0x1ed0fc0] Starting connection attempt to 86.189.112.78 port 443
[tcp @ 0x1ed0fc0] Successfully connected to 86.189.112.78 port 443
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'https://rr3---sn-cu-aigss.googlevideo.com/videoplayback?[... as above ...]':
  Metadata:
    major_brand     : dash
    minor_version   : 0
    compatible_brands: iso6avc1mp41
    creation_time   : 2022-03-04T03:33:03.000000Z
  Duration: 01:05:16.41, start: 0.000000, bitrate: 59 kb/s
    Stream #0:0(und): Video: h264 (Main), 1 reference frame (avc1 / 0x31637661), yuv420p(tv, bt709, progressive, left), 426x240 (432x240) [SAR 1:1 DAR 71:40], 0 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
    Metadata:
      creation_time   : 2022-03-04T03:33:03.000000Z
      handler_name    : ISO Media file produced by Google Inc.
Output #0, mp4, to 'file:How Ludwig Became The Biggest Twitch Streamer…Then Left For Youtube-z_czmz_bJqk.f133.mp4.part':
  Metadata:
    major_brand     : dash
    minor_version   : 0
    compatible_brands: iso6avc1mp41
    encoder         : Lavf58.45.100
    Stream #0:0(und): Video: h264 (Main), 1 reference frame (avc1 / 0x31637661), yuv420p(tv, bt709, progressive, left), 426x240 (0x0) [SAR 1:1 DAR 71:40], q=2-31, 0 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 24k tbc (default)
    Metadata:
      creation_time   : 2022-03-04T03:33:03.000000Z
      handler_name    : ISO Media file produced by Google Inc.
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
...
256kB time=00:00:37.10 bitrate=  56.5kbits/No more output streams to write to, finishing.
Not writing 'clli' atom. No content light level info.
Not writing 'mdcv' atom. Missing mastering metadata.
frame=  998 fps= 41 q=-1.0 Lsize=     339kB time=00:00:39.10 bitrate=  71.0kbits/s speed= 1.6x    
video:328kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 3.509154%
Input file #0 (https://rr3---sn-cu-aigss.googlevideo.com/videoplayback?[... as above ...]):
  Input stream #0:0 (video): 999 packets read (335399 bytes); 
  Total: 999 packets (335399 bytes) demuxed
Output file #0 (file:How Ludwig Became The Biggest Twitch Streamer…Then Left For Youtube-z_czmz_bJqk.f133.mp4.part):
  Output stream #0:0 (video): 998 packets muxed (335380 bytes); 
  Total: 998 packets (335380 bytes) muxed
[AVIOContext @ 0x2149b40] Statistics: 2 seeks, 5 writeouts
[AVIOContext @ 0x1ec1480] Statistics: 385985 bytes read, 1 seeks
[ffmpeg] Downloaded 347149 bytes
[download] 100% of 339.01KiB in 00:28
[debug] Invoking downloader on u'https://rr3---sn-cu-aigss.googlevideo.com/videoplayback?[... as above ...]'
[download] Destination: How Ludwig Became The Biggest Twitch Streamer…Then Left For Youtube-z_czmz_bJqk.f140.m4a
[debug] ffmpeg command line: ffmpeg -y -loglevel verbose -headers 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.90 Safari/537.36
' -ss 947673ms -to 986799ms -i 'https://rr3---sn-cu-aigss.googlevideo.com/videoplayback?[... as above ...]' -c copy -f ipod 'file:How Ludwig Became The Biggest Twitch Streamer…Then Left For Youtube-z_czmz_bJqk.f140.m4a.part'
ffmpeg version 4.3-2ubuntu0~ppa16.04+8 Copyright (c) 2000-2020 the FFmpeg developers
...
[tcp @ 0x1f69100] Starting connection attempt to 86.189.112.78 port 443
[tcp @ 0x1f69100] Successfully connected to 86.189.112.78 port 443
[tcp @ 0x21b4880] Starting connection attempt to 86.189.112.78 port 443
[tcp @ 0x21b4880] Successfully connected to 86.189.112.78 port 443
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'https://rr3---sn-cu-aigss.googlevideo.com/videoplayback?[... as above ...]':
  Metadata:
    major_brand     : dash
    minor_version   : 0
    compatible_brands: iso6mp41
    creation_time   : 2022-03-04T03:15:26.000000Z
  Duration: 01:05:16.46, start: 0.000000, bitrate: 129 kb/s
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 0 kb/s (default)
    Metadata:
      creation_time   : 2022-03-04T03:15:26.000000Z
      handler_name    : ISO Media file produced by Google Inc.
[ipod @ 0x21ac700] Warning, extension is not .m4a nor .m4v Quicktime/Ipod might not play the file
Output #0, ipod, to 'file:How Ludwig Became The Biggest Twitch Streamer…Then Left For Youtube-z_czmz_bJqk.f140.m4a.part':
  Metadata:
    major_brand     : dash
    minor_version   : 0
    compatible_brands: iso6mp41
    encoder         : Lavf58.45.100
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 0 kb/s (default)
    Metadata:
      creation_time   : 2022-03-04T03:15:26.000000Z
      handler_name    : ISO Media file produced by Google Inc.
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[tcp @ 0x21b4a80] Starting connection attempt to 86.189.112.78 port 443
[tcp @ 0x21b4a80] Successfully connected to 86.189.112.78 port 443
No more output streams to write to, finishing.1kbits/s speed=1.39x        
size=     619kB time=00:00:39.10 bitrate= 129.7kbits/s speed=1.43x    
video:0kB audio:612kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.209692%
Input file #0 (https://rr3---sn-cu-aigss.googlevideo.com/videoplayback?[... as above ...]):
  Input stream #0:0 (audio): 1687 packets read (626936 bytes); 
  Total: 1687 packets (626936 bytes) demuxed
Output file #0 (file:How Ludwig Became The Biggest Twitch Streamer…Then Left For Youtube-z_czmz_bJqk.f140.m4a.part):
  Output stream #0:0 (audio): 1686 packets muxed (626606 bytes); 
  Total: 1686 packets (626606 bytes) muxed
[AVIOContext @ 0x2429080] Statistics: 2 seeks, 6 writeouts
[AVIOContext @ 0x21a4340] Statistics: 671744 bytes read, 2 seeks
[ffmpeg] Downloaded 634186 bytes
[download] 100% of 619.32KiB in 00:30
[ffmpeg] Merging formats into "How Ludwig Became The Biggest Twitch Streamer…Then Left For Youtube-z_czmz_bJqk.mp4"
[debug] ffmpeg command line: ffmpeg -y -loglevel 'repeat+info' -i 'file:How Ludwig Became The Biggest Twitch Streamer…Then Left For Youtube-z_czmz_bJqk.f133.mp4' -i 'file:How Ludwig Became The Biggest Twitch Streamer…Then Left For Youtube-z_czmz_bJqk.f140.m4a' -c copy -map '0:v:0' -map '1:a:0' 'file:How Ludwig Became The Biggest Twitch Streamer…Then Left For Youtube-z_czmz_bJqk.temp.mp4'
Deleting original file How Ludwig Became The Biggest Twitch Streamer…Then Left For Youtube-z_czmz_bJqk.f133.mp4 (pass -k to keep)
Deleting original file How Ludwig Became The Biggest Twitch Streamer…Then Left For Youtube-z_czmz_bJqk.f140.m4a (pass -k to keep)
$

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I meant fragmented dash formats, not just video in dash container. Like this:

❯ py -m youtube_dl -v -f 303 https://youtube.com/clip/UgkxjUJxIAtXzBpOoEPx3gBzv1nAcDUHCUZh
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', '-f', '303', 'https://youtube.com/clip/UgkxjUJxIAtXzBpOoEPx3gBzv1nAcDUHCUZh']
[debug] Encodings: locale cp65001, fs utf-8, out utf-8, pref cp65001
[debug] youtube-dl version 2021.12.17
[debug] Python version 3.10.4 (CPython) - Windows-10-10.0.22000-SP0
[debug] exe versions: ffmpeg N-105465-gbedb4bac1c-20220206, ffprobe N-105465-gbedb4bac1c-20220206, phantomjs 2.1.1
[debug] Proxy map: {}
[youtube:tab] clip: Downloading webpage
[youtube] FoRlmsroon0: Downloading webpage
[youtube] FoRlmsroon0: Downloading MPD manifest
[debug] [youtube] Decrypted nsig mZNiLVhyyxlgmHA2 => wGpxwe1wxClyHw
[debug] [youtube] Decrypted nsig nTAjcE34-I5tnPI8 => 10jCIsllCZUuMw
[debug] Invoking downloader on 'https://manifest.googlevideo.com/api/manifest/dash/expire/1649879738/ei/WtZWYvraJfO24-EPnqKKwAY/ip/49.37.226.65/id/1684659acae8a27d/source/youtube/requiressl/yes/playback_host/rr4---sn-gwpa-jjwe.googlevideo.com/mh/6d/mm/31%2C29/mn/sn-gwpa-jjwe%2Csn-gwpa-h55y/ms/au%2Crdu/mv/m/mvi/4/pl/20/tx/24027683/txs/24027683%2C24027684%2C24027685%2C24027686%2C24067850/hfr/all/as/fmp4_audio_clear%2Cwebm_audio_clear%2Cwebm2_audio_clear%2Cfmp4_sd_hd_clear%2Cwebm2_sd_hd_clear/initcwndbps/287500/spc/4ocVC7i38GjMFcbJNCfvUCmIXd8u/vprv/1/mt/1649857763/fvip/4/keepalive/yes/fexp/24001373%2C24007246/itag/0/sparams/expire%2Cei%2Cip%2Cid%2Csource%2Crequiressl%2Ctx%2Ctxs%2Chfr%2Cas%2Cspc%2Cvprv%2Citag/sig/AOq0QJ8wRgIhAJSVJCMUyzfzjbIjwIDp37I-f6ZwO8Y5MNEpjgh3ZmfvAiEAjHEh7s_ePK_f9of2bZeC8gX5HKG0aP_uPjCWIc0wQKI%3D/lsparams/playback_host%2Cmh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps/lsig/AG3C_xAwRAIgQYutBBksmq7ytoUrAgYtFWjzzxSpN5Gvq4M2XH5MAGkCIHolNVTJv6HiTEP-uqOsUka2o8XH3Ap2mpDQmOGVmJGt'
[download] Destination: Longplay - Pokemon Platinum (Part 1 of 3)-FoRlmsroon0.webm
[debug] ffmpeg command line: ffmpeg -y -loglevel verbose -headers "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.108 Safari/537.36
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: en-us,en;q=0.5
" -ss 7137ms -to 22137ms -i "https://manifest.googlevideo.com/api/manifest/dash/expire/1649879738/ei/WtZWYvraJfO24-EPnqKKwAY/ip/49.37.226.65/id/1684659acae8a27d/source/youtube/requiressl/yes/playback_host/rr4---sn-gwpa-jjwe.googlevideo.com/mh/6d/mm/31%2C29/mn/sn-gwpa-jjwe%2Csn-gwpa-h55y/ms/au%2Crdu/mv/m/mvi/4/pl/20/tx/24027683/txs/24027683%2C24027684%2C24027685%2C24027686%2C24067850/hfr/all/as/fmp4_audio_clear%2Cwebm_audio_clear%2Cwebm2_audio_clear%2Cfmp4_sd_hd_clear%2Cwebm2_sd_hd_clear/initcwndbps/287500/spc/4ocVC7i38GjMFcbJNCfvUCmIXd8u/vprv/1/mt/1649857763/fvip/4/keepalive/yes/fexp/24001373%2C24007246/itag/0/sparams/expire%2Cei%2Cip%2Cid%2Csource%2Crequiressl%2Ctx%2Ctxs%2Chfr%2Cas%2Cspc%2Cvprv%2Citag/sig/AOq0QJ8wRgIhAJSVJCMUyzfzjbIjwIDp37I-f6ZwO8Y5MNEpjgh3ZmfvAiEAjHEh7s_ePK_f9of2bZeC8gX5HKG0aP_uPjCWIc0wQKI%3D/lsparams/playback_host%2Cmh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps/lsig/AG3C_xAwRAIgQYutBBksmq7ytoUrAgYtFWjzzxSpN5Gvq4M2XH5MAGkCIHolNVTJv6HiTEP-uqOsUka2o8XH3Ap2mpDQmOGVmJGt" -c copy -f webm "file:Longplay - Pokemon Platinum (Part 1 of 3)-FoRlmsroon0.webm.part"
ffmpeg version N-105465-gbedb4bac1c-20220206 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 11.2.0 (crosstool-NG 1.24.0.498_5075e1f)
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-nonfree --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --disable-libpulse --enable-libvmaf --disable-libxcb --disable-xlib --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librist --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --disable-libdrm --disable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-libplacebo --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-ldexeflags= --extra-libs=-lgomp --extra-version=20220206
  libavutil      57. 19.100 / 57. 19.100
  libavcodec     59. 20.100 / 59. 20.100
  libavformat    59. 17.101 / 59. 17.101
  libavdevice    59.  5.100 / 59.  5.100
  libavfilter     8. 26.101 /  8. 26.101
  libswscale      6.  5.100 /  6.  5.100
  libswresample   4.  4.100 /  4.  4.100
  libpostproc    56.  4.100 / 56.  4.100
[tcp @ 0000015aa51cd2c0] Starting connection attempt to 142.250.205.238 port 443
[tcp @ 0000015aa51cd2c0] Successfully connected to 142.250.205.238 port 443
[dash @ 0000015aa6cc30c0] DASH request for url 'https://rr4---sn-gwpa-jjwe.googlevideo.com/videoplayback/expire/1649879738/ei/WtZWYvraJfO24-EPnqKKwAY/ip/49.37.226.65/id/1684659acae8a27d/itag/133/source/yt_otf/requiressl/yes/mh/6d/mm/31,29/mn/sn-gwpa-jjwe,sn-gwpa-h55y/ms/au,rdu/mv/m/mvi/4/pl/20/initcwndbps/287500/spc/4ocVC7i38GjMFcbJNCfvUCmIXd8u/vprv/1/ratebypass/yes/mime/video%2Fmp4/otfp/1/otf/1/lmt/1572921815247141/mt/1649857763/fvip/4/keepalive/yes/fexp/24001373,24007246/sparams/expire,ei,ip,id,itag,source,requiressl,spc,vprv,ratebypass,mime,otfp,otf,lmt/sig/AOq0QJ8wRQIhAPO1Pkz6IMlRKc4aonSkl6Ku2FtDo-xXTKTPTKTvwwCrAiBIAip_h_KwUoac-Ttx3xqprIAoKR1aEvdXIQ-NcQ4_yw%3D%3D/lsparams/mh,mm,mn,ms,mv,mvi,pl,initcwndbps/lsig/AG3C_xAwRgIhAICIUdsdHnCnzQDDLAAl5puJUP80pvPZ8liBsw-cQY2iAiEA5crYA3kP2k02gwdBMfoHEBovPBiwP2GY9NEPrb2Jyzs%3D/sq/0', offset 0
[tcp @ 0000015aa6f09080] Starting connection attempt to 49.44.225.143 port 443
[tcp @ 0000015aa6f09080] Successfully connected to 49.44.225.143 port 443
... # Lots of ffmpeg output
[AVIOContext @ 0000015aa95b3700] Statistics: 32768 bytes read, 0 seeks
[dash @ 0000015aa6cc30c0] dash_seek with SegmentTimeline start n_timelines[2736] last_seq_no[2735].
[dash @ 0000015aa6cc30c0] dash_seek with SegmentTimeline end cur_seq_no[0].
[dash @ 0000015aa6cc30c0] DASH request for url 'https://rr4---sn-gwpa-jjwe.googlevideo.com/videoplayback/expire/1649879738/ei/WtZWYvraJfO24-EPnqKKwAY/ip/49.37.226.65/id/1684659acae8a27d/itag/251/source/youtube/requiressl/yes/mh/6d/mm/31,29/mn/sn-gwpa-jjwe,sn-gwpa-h55y/ms/au,rdu/mv/m/mvi/4/pl/20/initcwndbps/287500/spc/4ocVC7i38GjMFcbJNCfvUCmIXd8u/vprv/1/ratebypass/yes/mime/audio%2Fwebm/otfp/1/gir/yes/clen/455717854/lmt/1572921788922566/dur/27353.621/mt/1649857763/fvip/4/keepalive/yes/fexp/24001373,24007246/sparams/expire,ei,ip,id,itag,source,requiressl,spc,vprv,ratebypass,mime,otfp,gir,clen,lmt,dur/sig/AOq0QJ8wRQIgTc9XTImwl4iPlEsm9yLsvfnHOysvoRu9bdHVmVUDT3oCIQCSXUlpAdA5okNhfy7-Is-IJNwJmC4jaNd_4UaUz8QEdQ%3D%3D/lsparams/mh,mm,mn,ms,mv,mvi,pl,initcwndbps/lsig/AG3C_xAwRQIhAJeys_shPr849LCrTitHX-I0UBSGZxn5RUIzz5u4i-g_AiB0AjIDduZ_uTykcFOKD7w4sedhCHLca3lgO0qZQ3u39Q%3D%3D/range/50474-219109', offset 0
[tcp @ 0000015aa878e200] Starting connection attempt to 49.44.225.143 port 443
[tcp @ 0000015aa878e200] Successfully connected to 49.44.225.143 port 443
Input #0, dash, from 'https://manifest.googlevideo.com/api/manifest/dash/expire/1649879738/ei/WtZWYvraJfO24-EPnqKKwAY/ip/49.37.226.65/id/1684659acae8a27d/source/youtube/requiressl/yes/playback_host/rr4---sn-gwpa-jjwe.googlevideo.com/mh/6d/mm/31%2C29/mn/sn-gwpa-jjwe%2Csn-gwpa-h55y/ms/au%2Crdu/mv/m/mvi/4/pl/20/tx/24027683/txs/24027683%2C24027684%2C24027685%2C24027686%2C24067850/hfr/all/as/fmp4_audio_clear%2Cwebm_audio_clear%2Cwebm2_audio_clear%2Cfmp4_sd_hd_clear%2Cwebm2_sd_hd_clear/initcwndbps/287500/spc/4ocVC7i38GjMFcbJNCfvUCmIXd8u/vprv/1/mt/1649857763/fvip/4/keepalive/yes/fexp/24001373%2C24007246/itag/0/sparams/expire%2Cei%2Cip%2Cid%2Csource%2Crequiressl%2Ctx%2Ctxs%2Chfr%2Cas%2Cspc%2Cvprv%2Citag/sig/AOq0QJ8wRgIhAJSVJCMUyzfzjbIjwIDp37I-f6ZwO8Y5MNEpjgh3ZmfvAiEAjHEh7s_ePK_f9of2bZeC8gX5HKG0aP_uPjCWIc0wQKI%3D/lsparams/playback_host%2Cmh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps/lsig/AG3C_xAwRAIgQYutBBksmq7ytoUrAgYtFWjzzxSpN5Gvq4M2XH5MAGkCIHolNVTJv6HiTEP-uqOsUka2o8XH3Ap2mpDQmOGVmJGt':
  Duration: 07:35:53.00, start: -0.007000, bitrate: N/A
  Program 0
  Stream #0:0: Video: h264 (Main), 1 reference frame (avc1 / 0x31637661), yuv420p(tv, bt709, progressive, left), 426x240 (432x240) [SAR 1:1 DAR 71:40], 34 kb/s, 30 fps, 30 tbr, 90k tbn (default)
    Metadata:
      variant_bitrate : 242000
      id              : 133
  Stream #0:1: Video: h264 (Main), 1 reference frame (avc1 / 0x31637661), yuv420p(tv, bt709, progressive, left), 640x360 (640x368) [SAR 1:1 DAR 16:9], 0 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Metadata:
      variant_bitrate : 656418
      id              : 134
  Stream #0:2: Video: h264 (Main), 1 reference frame (avc1 / 0x31637661), yuv420p(tv, bt709, progressive, left), 854x480 (864x480) [SAR 1:1 DAR 427:240], 88 kb/s, 30 fps, 30 tbr, 90k tbn (default)
    Metadata:
      variant_bitrate : 1155000
      id              : 135
  Stream #0:3: Video: h264 (Main), 1 reference frame (avc1 / 0x31637661), yuv420p(tv, bt709, progressive, left), 256x144 [SAR 1:1 DAR 16:9], 15 kb/s, 30 fps, 30 tbr, 90k tbn (default)
    Metadata:
      variant_bitrate : 108000
      id              : 160
  Stream #0:4: Video: h264 (Main), 1 reference frame (avc1 / 0x31637661), yuv420p(tv, bt709, progressive, left), 1280x720 [SAR 1:1 DAR 16:9], 181 kb/s, 30 fps, 30 tbr, 90k tbn (default)
    Metadata:
      variant_bitrate : 2310000
      id              : 136
  Stream #0:5: Video: h264 (Main), 1 reference frame (avc1 / 0x31637661), yuv420p(tv, bt709, progressive, left), 1280x720 [SAR 1:1 DAR 16:9], 243 kb/s, 60 fps, 60 tbr, 90k tbn (default)
    Metadata:
      variant_bitrate : 3465000
      id              : 298
  Stream #0:6: Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(tv, bt709, progressive, left), 1920x1080 (1920x1088) [SAR 1:1 DAR 16:9], 0 kb/s, 60 fps, 60 tbr, 15360 tbn (default)
    Metadata:
      variant_bitrate : 6645876
      id              : 299
  Stream #0:7: Video: vp9 (Profile 0), 1 reference frame, yuv420p(tv, bt709/unknown/unknown), 426x240, 30.30 fps, 30 tbr, 1k tbn (default)
    Metadata:
      variant_bitrate : 220500
      id              : 242
  Stream #0:8: Video: vp9 (Profile 0), 1 reference frame, yuv420p(tv, bt709/unknown/unknown), 640x360, 30.30 fps, 30 tbr, 1k tbn (default)
    Metadata:
      variant_bitrate : 405720
      id              : 243
  Stream #0:9: Video: vp9 (Profile 0), 1 reference frame, yuv420p(tv, bt709/unknown/unknown), 854x480, 30.30 fps, 30 tbr, 1k tbn (default)
    Metadata:
      variant_bitrate : 752640
      id              : 244
  Stream #0:10: Video: vp9 (Profile 0), 1 reference frame, yuv420p(tv, bt709/unknown/unknown), 256x144, 30.30 fps, 30 tbr, 1k tbn (default)
    Metadata:
      variant_bitrate : 95000
      id              : 278
  Stream #0:11: Video: vp9 (Profile 0), 1 reference frame, yuv420p(tv, bt709/unknown/unknown), 1280x720, 30.30 fps, 30 tbr, 1k tbn (default)
    Metadata:
      variant_bitrate : 1505280
      id              : 247
  Stream #0:12: Video: vp9 (Profile 0), 1 reference frame, yuv420p(tv, bt709/unknown/unknown), 1280x720, 62.50 fps, 60 tbr, 1k tbn (default)
    Metadata:
      variant_bitrate : 2646000
      id              : 302
  Stream #0:13: Video: vp9 (Profile 0), 1 reference frame, yuv420p(tv, bt709/unknown/unknown), 1920x1080, 62.50 fps, 60 tbr, 1k tbn (default)
    Metadata:
      variant_bitrate : 4410000
      id              : 303
  Stream #0:14: Audio: aac (HE-AAC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 0 kb/s (default)
    Metadata:
      variant_bitrate : 76024
      id              : 139
  Stream #0:15: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 0 kb/s (default)
    Metadata:
      variant_bitrate : 156711
      id              : 140
  Stream #0:16: Audio: opus, 48000 Hz, stereo, fltp, delay 312 (default)
    Metadata:
      variant_bitrate : 175270
      id              : 251
[webm @ 0000015aa6e355c0] Only VP8 or VP9 or AV1 video and Vorbis or Opus audio and WebVTT subtitles are supported for WebM.
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:1 --
Stream mapping:
  Stream #0:6 -> #0:0 (copy)
  Stream #0:14 -> #0:1 (copy)
    Last message repeated 1 times
[AVIOContext @ 0000015aa6cd2580] Statistics: 264 bytes written, 0 seeks, 1 writeouts
[AVIOContext @ 0000015aa6cd1440] Statistics: 32768 bytes read, 0 seeks
[AVIOContext @ 0000015aa6cd1700] Statistics: 32768 bytes read, 0 seeks
[AVIOContext @ 0000015aa6cd2f80] Statistics: 49152 bytes read, 0 seeks
[AVIOContext @ 0000015aa95b3840] Statistics: 28427 bytes read, 0 seeks
[AVIOContext @ 0000015aa95b39c0] Statistics: 32768 bytes read, 0 seeks
[AVIOContext @ 0000015aa95b4100] Statistics: 32768 bytes read, 0 seeks
[AVIOContext @ 0000015aa95b4280] Statistics: 14646 bytes read, 0 seeks
[AVIOContext @ 0000015aa95b3b40] Statistics: 32768 bytes read, 0 seeks
[AVIOContext @ 0000015aa95b3cc0] Statistics: 32768 bytes read, 0 seeks
[AVIOContext @ 0000015aa95b3e00] Statistics: 65536 bytes read, 0 seeks
[AVIOContext @ 0000015aa95b43c0] Statistics: 32768 bytes read, 0 seeks
[AVIOContext @ 0000015aa6cd2280] Statistics: 32768 bytes read, 0 seeks
[AVIOContext @ 0000015aa6cd2400] Statistics: 32768 bytes read, 0 seeks
[AVIOContext @ 0000015aa6cd2c80] Statistics: 26486 bytes read, 0 seeks
[AVIOContext @ 0000015aa6cd1cc0] Statistics: 32768 bytes read, 0 seeks
[AVIOContext @ 0000015aa6cd12c0] Statistics: 32768 bytes read, 0 seeks
[AVIOContext @ 0000015aa6cd2e00] Statistics: 32768 bytes read, 0 seeks
[AVIOContext @ 0000015aa6cc5bc0] Statistics: 3639581 bytes read, 0 seeks


ERROR: ffmpeg exited with code 1
  File "D:\Programs\scoop\apps\python\current\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\Programs\scoop\apps\python\current\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "REDACTED\youtube_dl\__main__.py", line 19, in <module>
    youtube_dl.main()
  File "REDACTED\youtube_dl\__init__.py", line 475, in main
    _real_main(argv)
  File "REDACTED\youtube_dl\__init__.py", line 465, in _real_main
    retcode = ydl.download(all_urls)
  File "REDACTED\youtube_dl\YoutubeDL.py", line 2077, in download
    res = self.extract_info(
  File "REDACTED\youtube_dl\YoutubeDL.py", line 808, in extract_info
    return self.__extract_info(url, ie, download, extra_info, process)
  File "REDACTED\youtube_dl\YoutubeDL.py", line 815, in wrapper
    return func(self, *args, **kwargs)
  File "REDACTED\youtube_dl\YoutubeDL.py", line 847, in __extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "REDACTED\youtube_dl\YoutubeDL.py", line 885, in process_ie_result
    return self.extract_info(ie_result['url'],
  File "REDACTED\youtube_dl\YoutubeDL.py", line 808, in extract_info
    return self.__extract_info(url, ie, download, extra_info, process)
  File "REDACTED\youtube_dl\YoutubeDL.py", line 815, in wrapper
    return func(self, *args, **kwargs)
  File "REDACTED\youtube_dl\YoutubeDL.py", line 847, in __extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "REDACTED\youtube_dl\YoutubeDL.py", line 881, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "REDACTED\youtube_dl\YoutubeDL.py", line 1692, in process_video_result
    self.process_info(new_info)
  File "REDACTED\youtube_dl\YoutubeDL.py", line 1985, in process_info
    success = dl(filename, info_dict)
  File "REDACTED\youtube_dl\YoutubeDL.py", line 1924, in dl
    return fd.download(name, info)
  File "REDACTED\youtube_dl\downloader\common.py", line 366, in download
    return self.real_download(filename, info_dict)
  File "REDACTED\youtube_dl\downloader\external.py", line 63, in real_download
    self.report_error('%s exited with code %d' % (
  File "REDACTED\youtube_dl\downloader\common.py", line 165, in report_error
    self.ydl.report_error(*args, **kargs)
  File "REDACTED\youtube_dl\YoutubeDL.py", line 628, in report_error
    self.trouble(error_message, tb)
  File "REDACTED\youtube_dl\YoutubeDL.py", line 590, in trouble
    tb_data = traceback.format_list(traceback.extract_stack())

@dirkf
Copy link
Contributor Author

dirkf commented Apr 14, 2022

I did wonder. I get just this with 4.3.2:

[dash @ 0x1c07fc0] Manifest too large: 3639796

which is similar to the problem in the memory issue reported for yt-dlp.

One could skip DASH formats for clips, or fix ffmpeg (apparently that happened but your ffmpeg looks to be newer -- even if they can't name the versions in way that shows what release they're based on -- and fails differently), or hope that some DASH formats sent by YT are acceptable.

In your output, format 303 is being selected in yt-dl but ffmpeg command is selecting 299+139 (avc1+aac) which aren't valid for webm. Is that why the error is being returned?

@pukkandan
Copy link
Contributor

or fix ffmpeg (apparently that happened but your ffmpeg looks to be newer -

Yes, that issue has been fixed by ffmpeg

In your output, format 303 is being selected in yt-dl but ffmpeg command is selecting 299+139 (avc1+aac) which aren't valid for webm. Is that why the error is being returned?

Right! That was indeed the issue

We should pass the correct stream using -map yt-dlp/yt-dlp@6251555 yt-dlp/yt-dlp@234416e. Note that the implementation will need to be slightly different for youtube-dl due to lack of yt-dlp/yt-dlp@18e674b

@bharathmuppa
Copy link

Eagerly waiting for this.

clip_times = (int_or_none(clip_data.get('startTimeMs')),
int_or_none(clip_data.get('endTimeMs')))
if None not in clip_times:
self._downloader.params['_clip_args'] = '%gms,%gms' % clip_times
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! I've just discovered, that if you try to download a clip which was made from a long stream - it will fail. In my example, I've tried to download a clip which starts at 6:02:20 and ends at 6:02:20. Something bad happens here at integer to string conversion. Here is a fix, which worked for me

Suggested change
self._downloader.params['_clip_args'] = '%gms,%gms' % clip_times
self._downloader.params['_clip_args'] = f'{clip_times[0]}ms,{clip_times[1]}ms'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be no good for yt-dl. The problem is that we made these millisecond counts integers and are then formatting them as g-floats, where a large enough number will be represented in mantissa/exponent format.

Suggested change
self._downloader.params['_clip_args'] = '%gms,%gms' % clip_times
self._downloader.params['_clip_args'] = '%dms,%dms' % clip_times

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for YouTube clips
4 participants