question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trimming with ffmpeg and --postprocessing-args does not work anymore

See original GitHub issue
  • 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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
schorschiecommented, Aug 23, 2022

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)
2reactions
dirkfcommented, Aug 26, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues in trimming a video with FFmpeg - Video StackExchange
I have a .webm video captured through a web browser. Using ffmpeg, I want to trim it into its first 30s without re-encoding...
Read more >
FFMPEG not "cutting" as expected - Stack Overflow
When doing stream copy or when -noaccurate_seek is used, it will be preserved. When used as an output option (before an output filename), ......
Read more >
Cutting Videos Based on Start and End Time using FFmpeg
In this tutorial, we're going to see how we can use the Linux command-line to cut videos. We'll cover a few approaches to...
Read more >
How can I remove multiple segments from a video using ...
I am trying to do the same thing from the command-line with FFmpeg. I know how to cut a single segment to a...
Read more >
ffmpeg Documentation
However, it might not work in some cases because of many factors. ... If the alignment is not met the cropping will be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found