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
131.47k stars 9.96k forks source link

Pass arguments to ffmpeg #29074

Open suntong opened 3 years ago

suntong commented 3 years ago

Checklist

Question

Is it possible to pass arguments to ffmpeg directly from youtube-dl cli?

I did some search, and have found one example in the python code level, but I'm wondering if it is possible from youtube-dl cli.

The use case is, for --extract-audio to convert video files to audio-only files, or doing audio-only downloading, it'll be super if I can increase the audio volume using ffmpeg option on the fly, instead of me doing it again afterwards.

I don't know if it is even possible, so I'm just asking. thx

pukkandan commented 3 years ago

--postprocessor-args

suntong commented 3 years ago

Thanks.

Just even having used -v I cannot really tell if my option has been passed to ffmpeg or not. Anyway, thanks.

shortthirdman commented 2 years ago

--postprocessor-args

Hey @pukkandan but using this nothing is being passed after using -v for verbosity.

suntong commented 2 years ago

Agree, nothing is being passed.

Thanks the for the confirmation, thus, reopening the issue.

ghost commented 2 years ago

Please provide the verbose log.

UliGall commented 2 years ago

I am trying to download a video, but the audio is empty, so I wanted to set analyzeduration and probesize higher (as recommended), to a value referenced here. I assumed that it should be able to do that with --postprocessor-args, which it seems does not work.

I executed following command (Ubuntu 20.04 on WSL2): youtube-dl https://URL_REPLACED/video_1629/1806/1806.m3u8 --postprocessor-args "-analyzeduration 2147483647 -probesize 2147483647" -v

Respective result @kikuyan:

[debug] System config: [] [debug] User config: [] [debug] Custom config: [] [debug] Command-line args: ['https://URL_REPLACED/video_1629/1806/1806.m3u8', '--postprocessor-args', '-analyzeduration 2147483647 -probesize 2147483647', '-v'] [debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8 [debug] youtube-dl version 2021.06.06 [debug] Python version 3.8.10 (CPython) - Linux-5.10.16.3-microsoft-standard-WSL2-x86_64-with-glibc2.29 [debug] exe versions: ffmpeg 4.2.4, ffprobe 4.2.4 [debug] Proxy map: {} [generic] 1806: Requesting header [generic] 1806: Downloading m3u8 information [debug] Default format spec: bestvideo+bestaudio/best [debug] Invoking downloader on 'https://URL_REPLACED/video_1629/1806/1806_hls.m3u8' [download] Destination: 1806-1806.mp4 [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/70.0.3538.15 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 ' -i https://URL_REPLACED/video_1629/1806/1806_hls.m3u8 -c copy -f mp4 file:1806-1806.mp4.part ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers built with gcc 9 (Ubuntu 9.3.0-10ubuntu2) configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 31.100 / 56. 31.100 libavcodec 58. 54.100 / 58. 54.100 libavformat 58. 29.100 / 58. 29.100 libavdevice 58. 8.100 / 58. 8.100 libavfilter 7. 57.100 / 7. 57.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 5.100 / 5. 5.100 libswresample 3. 5.100 / 3. 5.100 libpostproc 55. 5.100 / 55. 5.100 [tcp @ 0x5591834155c0] Starting connection attempt to 54.192.100.216 port 443 [tcp @ 0x5591834155c0] Successfully connected to 54.192.100.216 port 443 [hls @ 0x559183412500] Skip ('#EXT-X-VERSION:3') [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00001.ts', offset 0, playlist 0 [hls @ 0x559183412500] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00001.ts' for reading [tcp @ 0x5591836ecd00] Starting connection attempt to 54.192.100.216 port 443 [tcp @ 0x5591836ecd00] Successfully connected to 54.192.100.216 port 443 [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00002.ts', offset 0, playlist 0 [hls @ 0x559183412500] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00002.ts' for reading [tcp @ 0x559183712080] Starting connection attempt to 54.192.100.216 port 443 [tcp @ 0x559183712080] Successfully connected to 54.192.100.216 port 443 [h264 @ 0x559183a015c0] Reinit context to 1920x1088, pix_fmt: yuv420p [hls @ 0x559183412500] max_analyze_duration 5000000 reached at 5005000 microseconds st:0 [hls @ 0x559183412500] Could not find codec parameters for stream 1 (Audio: aac ([15][0][0][0] / 0x000F), 0 channels, fltp): unspecified sample rate Consider increasing the value for the 'analyzeduration' and 'probesize' options Input #0, hls, from 'https://URL_REPLACED/video_1629/1806/1806_hls.m3u8': Duration: 00:04:37.00, start: 2.033367, bitrate: 0 kb/s Program 0 Metadata: variant_bitrate : 0 Stream #0:0: Video: h264 (High), 1 reference frame ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, left), 1920x1080 (1920x1088) [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc Metadata: variant_bitrate : 0 Stream #0:1: Audio: aac ([15][0][0][0] / 0x000F), 0 channels, fltp Metadata: variant_bitrate : 0 Output #0, mp4, to 'file:1806-1806.mp4.part': Metadata: encoder : Lavf58.29.100 Stream #0:0: Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(tv, bt709, left), 1920x1080 (0x0) [SAR 1:1 DAR 16:9], q=2-31, 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc Metadata: variant_bitrate : 0 Stream mapping: Stream #0:0 -> #0:0 (copy) Press [q] to stop, [?] for help [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00003.ts', offset 0, playlist 0 [https @ 0x5591836ea740] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00003.ts' for reading [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00004.ts', offset 0, playlist 0 [https @ 0x559183709a40] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00004.ts' for reading [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00005.ts', offset 0, playlist 0 [https @ 0x5591836ea740] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00005.ts' for reading [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00006.ts', offset 0, playlist 0 [https @ 0x559183709a40] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00006.ts' for reading [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00007.ts', offset 0, playlist 0 [https @ 0x5591836ea740] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00007.ts' for reading [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00008.ts', offset 0, playlist 0 [https @ 0x559183709a40] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00008.ts' for reading [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00009.ts', offset 0, playlist 0 [https @ 0x5591836ea740] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00009.ts' for reading [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00010.ts', offset 0, playlist 0 [https @ 0x559183709a40] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00010.ts' for reading [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00011.ts', offset 0, playlist 0 [https @ 0x5591836ea740] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00011.ts' for reading [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00012.ts', offset 0, playlist 0 [https @ 0x559183709a40] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00012.ts' for reading [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00013.ts', offset 0, playlist 0 [https @ 0x5591836ea740] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00013.ts' for reading [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00014.ts', offset 0, playlist 0 [https @ 0x559183709a40] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00014.ts' for reading [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00015.ts', offset 0, playlist 0 [https @ 0x5591836ea740] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00015.ts' for reading [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00016.ts', offset 0, playlist 0 [https @ 0x559183709a40] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00016.ts' for reading [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00017.ts', offset 0, playlist 0 [https @ 0x5591836ea740] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00017.ts' for reading [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00018.ts', offset 0, playlist 0 [https @ 0x559183709a40] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00018.ts' for reading [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00019.ts', offset 0, playlist 0 [https @ 0x5591836ea740] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00019.ts' for reading [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00020.ts', offset 0, playlist 0 [https @ 0x559183709a40] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00020.ts' for reading [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00021.ts', offset 0, playlist 0 [https @ 0x5591836ea740] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00021.ts' for reading [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00022.ts', offset 0, playlist 0 [https @ 0x559183709a40] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00022.ts' for reading [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00023.ts', offset 0, playlist 0 [https @ 0x5591836ea740] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00023.ts' for reading [hls @ 0x559183412500] HLS request for url 'https://URL_REPLACED/video_1629/1806/1806_hls_00024.ts', offset 0, playlist 0 [https @ 0x559183709a40] Opening 'https://URL_REPLACED/video_1629/1806/1806_hls_00024.ts' for reading No more output streams to write to, finishing. frame= 8296 fps=4509 q=-1.0 Lsize= 7528kB time=00:04:36.74 bitrate= 222.9kbits/s speed= 150x video:7431kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.316245% Input file #0 (https://URL_REPLACED/video_1629/1806/1806_hls.m3u8): Input stream #0:0 (video): 8296 packets read (7608919 bytes); Input stream #0:1 (audio): 12975 packets read (4428800 bytes); Total: 21271 packets (12037719 bytes) demuxed Output file #0 (file:1806-1806.mp4.part): Output stream #0:0 (video): 8296 packets muxed (7608919 bytes); Total: 8296 packets (7608919 bytes) muxed [AVIOContext @ 0x559183e0bc40] Statistics: 2 seeks, 33 writeouts [AVIOContext @ 0x559183a03040] Statistics: 6142524 bytes read, 0 seeks [AVIOContext @ 0x55918370c9c0] Statistics: 7371668 bytes read, 0 seeks [AVIOContext @ 0x5591836f0140] Statistics: 833 bytes read, 0 seeks [ffmpeg] Downloaded 7709071 bytes [download] 100% of 7.35MiB in 00:02

Thanks in advance!

ghost commented 2 years ago

@UliGall In your case, ffmpeg IS downloading, not post-processing. You can pass arguments with --external-downloader-args.

FYI. There's a --hls-prefer-native option to make youtube-dl itself download HLS. However, using --hls-prefer-native and --postprocessor-args will give the same result as downloading with ffmpeg in your case. This is because youtube-dl is passing arguments to ffmpeg after input files.

UliGall commented 2 years ago

Thanks @kikuyan, that solved (at least) my problem!