1

I want to download certain sections from a youtube stream, currently I'm using this command to get the job done:

yt-dlp --download-sections "*30:15-1:40:25" $LINK       

the problem is that if the connection is lost just for a few minutes, the download has to start all over again, I'm also aware of this command:

youtube-dl --youtube-skip-dash-manifest -g "URL"

The two url outputs gets saved into urls[] in python and:

ffmpeg -y -ss "00:41:10" -i urls[0] -ss "00:41:10" -i urls[1] -map 0:v -map 1:a -ss 5 -t  "01:50:11" -c:v libx265 -c:a aac ../Clips/stream.mkv

That also has the problem of losing all downloaded if the connection is lost for a few minutes

I can't download the whole stream because it would take forever, so simply using:

youtube-dl $LINK

or

yt-dlp $LINK

it's not an option even though they offer reconnecting

1 Answers1

1

There are some (arguably) better forms of the ffmpeg command/arguments that could be used - although, admittedly, this still doesn't address the reconnection issue.

From Reddit - How to download specific parts of a livestream?,

ffmpeg -ss 11:23:32 -to 12:25:00 -i $(yt-dlp -g https://youtube.com/watch?v=EXAMPLE) ./my-clip.mp4

Video tutorial: https://www.youtube.com/watch?v=aBtbsfPrkcc

...

On linux you can schedule a command with the at command, cron, or systemd timer. I'm sure there's a way to schedule a command on windows but I don't know how.

If you pass -t hh:mm:ss instead of -to hh:mm:ss to ffmpeg, it will stop after the duration specified elapses instead of starting at a timestamp specified.

Altogether, the command could look like this

echo 'ffmpeg -y -t 01:00:00 -i $(yt-dlp -g https://www.youtube.com/watch?v=6JUHxDBMAXE) clip.ts' | at 21:00

A further note:

Windows used to have a command-line at.exe command, but it is depreciated on newer versions. It has been replaced with schtasks.exe. The Windows GUI for it is taskschd.msc

Greenonline
  • 2,390