[FFmpeg-user] How to download video stream starting at an earlier time?

DEF shaker.doc at gmail.com
Tue Aug 17 10:06:39 EEST 2021


On Tue, 17 Aug 2021 at 06:58, Bo Berglund <bo.berglund at gmail.com> wrote:
>
> On Mon, 16 Aug 2021 23:29:22 +0200, "Carlos E. R." <robin.listas at telefonica.net>
> wrote:
>
> >Google: download youtube video cut with ffmpeg
> >
> ><https://ostechnix.com/download-a-portion-of-youtube-video-with-youtube-dl-and-ffmpeg/>
> >
> >$ youtube-dl --external-downloader ffmpeg --external-downloader-args
> >"-ss 00:01:00.00 -to 00:02:00.00" -f best
> >"https://www.youtube.com/watch?v=dc7I-i7sPrg"
> >
> >or
> >
> >$ ffmpeg -ss 00:01:00 -to 00:02:00 -i "$(youtube-dl -f best --get-url
> >'https://www.youtube.com/watch?v=dc7I-i7sPrg')" -c:v copy -c:a copy
> >kiosk.mp4
> >
> Thanks for your suggestions!
>
> First I tried the second one as follows:
>
> ffmpeg -ss 06:06:00 -to 06:10:00 -i "$(youtube-dl -f 93 --get-url
> 'https://www.youtube.com/watch?v=DM-I6UugaFs')" -c:v copy -c:a copy
> testpastvideo.mp4
>

If you want to use youtube-dl in addition to ffmpeg, then remember
that  the command youtube-dl --get-url generates a two line stream.
One for the video and another for the audio..
you need a small shell script that handles both..

Try this (and notice that I have changed  4 minutes to seconds and use
-t instead.)


ffmpeg $(youtube-dl -g 'https://www.youtube.com/watch?v=DM-I6UugaFs' |
sed "s/.*/-ss 06:06:00 -i &/") -t 240  -c copy testpassvideo.mp4



> I assumed that it would start recording 6h 6m from the start of the stream
> (which is 12 hours long) and last until 6h 10m into the stream (duration 4
> minutes).
> But in fact it recorded from current time and did not stop after the 4 minutes
> so I had to manually stop it using the keyboard q key.
> So this attempt did not go into the past as requested.
>
> Then I tried this:
>
> youtube-dl --external-downloader ffmpeg --external-downloader-args "-ss
> 06:06:00.00 -to 06:10:00.00" -f 93 "https://www.youtube.com/watch?v=DM-I6UugaFs"
> -o testpastvideo3.mp4
>
> Again the recording did not stop after 4 minutes but had to be manually stopped,
> this time using Ctrl-C (since youtube-dl was the main program).
> This also recorded from current time rather than from the beginning of the
> stream plus the 6 hour offset
>
>


More information about the ffmpeg-user mailing list