youtube-dl: Trimming with ffmpeg and --postprocessing-args does not work anymore

  • I’ve verified that I’m running youtube-dl version 2021.06.06
  • I’ve checked that all provided URLs are alive and playable in a browser
  • I’ve checked that all URLs and arguments with special characters are properly quoted or escaped
  • I’ve searched the bugtracker for similar bug reports including closed ones
  • I’ve read bugs section in FAQ

Hi,

a few weeks ago (sorry, I can’t remember when exactly), trimming downloaded videos using ffmpeg and the --postprocessor-args option ceased to work.

Previously, I used this command, which had been working for several weeks:

youtube-dl --postprocessor-args "-ss 00:00:39.00 -to 00:01:26.00" "https://www.youtube.com/watch?v=uYSt8K8VP6k"

Then the videos downloaded correctly but was not trimmed. So I updated everything (brew upgrade && brew update) and tried this instead:

youtube-dl --postprocessor-args "-ss 00:00:39.00 -c copy -map 0 -to 00:01:26.00" "https://www.youtube.com/watch?v=uYSt8K8VP6k"

To no avail. I tried adding --postprocessor ffmpeg. I tried encircling time codes between single quotes. I also tried putting the option at the end of the command.

Obviously, I have ffmpeg installed and post-trimming the video with a separate call to ffmpeg does work:

ffmpeg -ss $START -i "${INFILE}" -c copy -map 0 -to $END "${OUTFILE}"

So I don’t know what happens and, even more shocking, nothing interesting prints in the log when I add the --verboseoption.

I know that ffmpeg is called by youtube-dl because if I try --embed-subsI get a [ffmpeg] No subtitles to embed error

Does anyone can reproduce this?

Verbose log:

[debug] System config: []
[debug] User config: ['--format', 'best']
[debug] Custom config: []
[debug] Command-line args: ['--postprocessor-args', '-ss 00:00:39.00 -c copy -map 0 -to 00:01:26.00', 'https://www.youtube.com/watch?v=uYSt8K8VP6k', '--verbose']
[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.9.9 (CPython) - macOS-10.14.6-x86_64-i386-64bit
[debug] exe versions: ffmpeg 4.4.1, ffprobe 4.4.1
[debug] Proxy map: {}
[youtube] uYSt8K8VP6k: Downloading webpage
[debug] Invoking downloader on 'https://r5---sn-4gxx-25gy.googlevideo.com/videoplayback?expire=1638494644&ei=VB2pYYvBMMmz1wbe-aeoBg&ip=2a01%3Ae0a%3A914%3A6ed0%3A8db7%3A192e%3A3516%3A6492&id=o-AAeWNNUlGhZZx3oDj2rK-tb8rvsn35wow0u_ZFe3nZOt&itag=18&source=youtube&requiressl=yes&mh=c6&mm=31%2C26&mn=sn-4gxx-25gy%2Csn-hpa7kn7z&ms=au%2Conr&mv=m&mvi=5&nh=EAE%2C&pl=49&initcwndbps=715000&vprv=1&mime=video%2Fmp4&ns=HMdOMEw1IF-ZhoAULp9JzOkG&gir=yes&clen=5566437&ratebypass=yes&dur=97.593&lmt=1437448543536765&mt=1638472637&fvip=5&fexp=24001373%2C24007246&c=WEB&n=udAzlKow2YHPcZ9QxX_&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRgIhAPtzaYmxF3YSPLWpvebtZKAzQ8sM1U3Cordb-D1QQV84AiEAv9gzaA9RpW7mttXqv8Iu3XHq62Wrijpc5xkNJbdFvYs%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cnh%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhAKMpRfHB_GtqVSvkcO1eYImbkY9AGG3T2izbSuzLX-5WAiEA5hDpsxu9P88_sAtyYTfUcJghNb54gedwoUctZ4Wp2PY%3D'
[download] Destination: Quarter Pounder with cheese in Pulp Fiction scene-uYSt8K8VP6k.mp4
[download] 100% of 5.31MiB in 01:08

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Sorry, I should have seen the problem before: use an OUTPUT TEMPLATE, not a filename, with -o, and end it with .%(ext)s. The first download will be the .m4a and the extracted file will be the .mp3.

@dirkf: yes, that works! I’ve adapted my example with your help, thank you!

import os

youtube_url = 'https://youtu.be/o8Y_uR6ZDxo'
file_name = 'asdf'
skip_seconds = '00:00:42'

command_string = 'python -m youtube_dl -v -x --output "%s.%%(ext)s" --audio-format mp3 --audio-quality 128k --postprocessor-args "-ss %s" %s' % (
    file_name,
    skip_seconds,
    youtube_url)

print(command_string)
os.system(command_string)

Sorry, I should have seen the problem before: use an OUTPUT TEMPLATE, not a filename, with -o, and end it with .%(ext)s. The first download will be the native audio (opus or aac) and the extracted file will be the .mp3.

The first download will be the .m4a and the extracted file will be the .mp3.

Sorry, I’m not following… Did you mean to write the (opus-audio-only containing) webm (i.e. itag=251) ?

[debug] Invoking downloader on 'https://rr4---sn-h0jeln7l.googlevideo.com/videoplayback?expire=1661201834&ei=SpkDY-DjBoa7x_APiYOo6Ac&ip=2003:e0:1f1e:8a00:ec5a:5d72:25a2:1040&id=o-ALAPDpF2VWFLXHcYuG8fe_Y4680zKblE8V48w2ZpRVnW&itag=251&source=youtube&requiressl=yes&mh=0T&mm=31,29&mn=sn-h0jeln7l,sn-h0jeenld&ms=au,rdu&mv=m&mvi=4&pl=37&initcwndbps=1526250&vprv=1&mime=audio/webm&ns=uIQGkS0MkXqZtHT-OJYV-_MH&gir=yes&clen=4221936&dur=251.021&lmt=1582978133916193&mt=1661179776&fvip=4&keepalive=yes&fexp=24001373,24007246&c=WEB&rbqsm=fr&txp=5531432&n=TukQonFNyejxaZf4lm&sparams=expire,ei,ip,id,itag,source,requiressl,vprv,mime,ns,gir,clen,dur,lmt&lsparams=mh,mm,mn,ms,mv,mvi,pl,initcwndbps&lsig=AG3C_xAwRQIhAOQvUrdaq2LEx9tuBO3MX8_3VdZo-tW8PIbzZJLOj5EZAiASk632twK_h-MP2Ow8DFZFhL11NAtIRyGoh87Y2hjKkw==&sig=AOq0QJ8wRQIgWg_faLP1mNTxaMmI2jl6XVzSkQ5Vvh3-zBK-93Un2QACIQClIglNbUNLaqqmNjBlHOJF8d8ULIojCZHYfkV0fZZlzQ=='
[download] Destination: ROY KNOX x WTCHOUT - Shadows (Feat. Svniivan) [NCS Release]-o8Y_uR6ZDxo.webm

Edit: On an unrelated note, we have already a new yt player 0c356943 😜 :

[youtube] o8Y_uR6ZDxo: Downloading webpage
[youtube] o8Y_uR6ZDxo: Downloading player 0c356943
[info] Available formats for o8Y_uR6ZDxo:

😃

Postprocessing only runs if yt-dl “thinks” it necessary. When your --postprocessor-args were effective, you were piggybacking on that choice.

To force some ad hoc (ie, not programmed by yt-dl) postprocessing, such as time cropping the downloaded media as above, use --exec, or pipe the output to ffmpeg.

You are using --format best in your config, and there’s no post-processing to do in this case. Would work when video and audio are to be merged or using with some post-processing options.