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

Specify time interval #2063

Closed
4 tasks done
Labels
external issue Issue with an external tool or site

Comments

Copy link

Dec 20, 2021

Checklist

Question

I was wondering if there's a way to specify time interval to download, I have tried to use -ss and -to but it reported back with -t not an option (as noted at the bottom of readme, it's removed)

I have also found some info in issue #686, which did work for me, but somehow extracted with a slightly longer interval (included about 7 seconds before the specified time interval), and that also seems to be slower than typical download so I was wondering if there is another option (around 1-2% of full speed)

here's my line :
yt-dlp -f "bestaudio/best" --downloader ffmpeg --external-downloader-args "ffmpeg_i:-ss [time] -to [time]" --extract-audio --audio-quality 0 --audio-format opus [URL]

question Question label Dec 20, 2021
@pukkandan
Copy link
Member

but somehow extracted with a slightly longer interval (included about 7 seconds before the specified time interval)

That is normal. ffmpeg can only cut the video at nearest keyframe

and that also seems to be slower than typical download so I was wondering if there is another option.

It is slower because we are using ffmpeg to do the download. There is no other option

@hashimaziz1
Copy link

hashimaziz1 commented Jan 4, 2022

That is normal. ffmpeg can only cut the video at nearest keyframe

This isn't true, I regularly use FFmpeg to cut video accurately, it's perfectly possible to do when encoding the video (i.e. when not specifying c- copy or -c:v copy), it would make FFmpeg a very useless video editor otherwise. The problem is that it's done by using -ss and -t/-to to seek through the input rather than the output, but it appears yt-dlp defaults to always seeking through the output when using --external-downloader-args. See here for more information on seeking on input vs output.

@pukkandan
Copy link
Member

pukkandan commented Jan 4, 2022

but yt-dlp doesn't appear to allow this with the --external-downloader-args options

Just remove the _i to change it to an output arg

--external-downloader-args "ffmpeg:-ss ... -to ..."

@hashimaziz1
Copy link

hashimaziz1 commented Jan 5, 2022

but yt-dlp doesn't appear to allow this with the --external-downloader-args options

Just remove the _i to change it to an output arg

--external-downloader-args "ffmpeg:-ss ... -to ..."

Yeah my bad, you're right, I was confusing the seeking options even though I linked to the FFmpeg wiki page that explains them - seeking on input is the least accurate because it uses keyframes, not seeking on output. Seeking on output is what was necessary for accurate seeking.

The problem is that when I seek on output with:

yt-dlp --downloader ffmpeg --external-downloader-args "-ss 00:40:00.00 -to 00:40:55.00" "https://www.youtube.com/watch?v=w53JbQ4pMjE"

...I get the following error:

[tls @ 0000023ad84fa700] Error in the pull function.0:00.00 bitrate=N/A speed=   0x
[matroska,webm @ 0000023ad8501540] Read error
[tls @ 0000023ad84fa700] The specified session has been invalidated for some reason.
    Last message repeated 1 times
https://rr2---sn-8vq54vox03-xqpe.googlevideo.com/videoplayback?expire=1641423505&ei=Mc7VYebpArjCmLAP_b-44
As&ip=90.246.120.252&id=o-AN7HZ7YU5mN6DPHorgYqqM63DZfz9iwDtlCK9unur2jy&itag=251&source=youtube&requiressl
=yes&mh=Xi&mm=31%2C29&mn=sn-8vq54vox03-xqpe%2Csn-aigl6ner&ms=au%2Crdu&mv=m&mvi=2&pl=18&initcwndbps=196500
0&vprv=1&mime=audio%2Fwebm&gir=yes&clen=51983825&dur=3525.081&lmt=1633347724405414&mt=1641401582&fvip=2&k
eepalive=yes&fexp=24001373%2C24007246&c=ANDROID&txp=5432434&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource
%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIgQr7qjDNTd5Rvp27JbLDkPkRLyRDHjBypryo1
vyxM5oICIQC6U2WVmgC-nIHo8YdsN3pX6CEmLxQf4wStAn5avn6nUA%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2
Cinitcwndbps&lsig=AG3C_xAwRQIhAM1xfnu4ugRPg15TuqU-Q6Jh8sHgOCUfeYycCF1C6iHWAiAE9uDjprUxGEWMosAaKsdwmQjA3A3
7ZLnYyhekXKr9iw%3D%3D: I/O error
frame= 1569 fps=1.9 q=-1.0 Lsize=    3539kB time=00:00:54.96 bitrate= 527.5kbits/s speed=0.0674x
video:3528kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.332972%
[ffmpeg] Downloaded 3624339 bytes
[download] 100% of 3.46MiB in 13:36

And an output clip that is time-accurate but with no audio. Any idea how this might be fixed?

@pukkandan pukkandan reopened this Jan 6, 2022
@pukkandan
Copy link
Member

I can reproduce, but no idea why

@pukkandan pukkandan added external issue Issue with an external tool or site and removed question Question labels May 28, 2022
@pukkandan
Copy link
Member

No longer reproducible

@pukkandan pukkandan closed this as not planned Won't fix, can't repro, duplicate, stale Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external issue Issue with an external tool or site
Projects
None yet
Development

No branches or pull requests

3 participants