relidon
relidon

Reputation: 2292

how download m3u8 in chunks using ffmpeg?

I'm trying to convert m3u8 to mp4 and I found the following method that works

ffmpeg -i 'https://....m3u8' -bsf:a aac_adtstoasc \
    -vcodec copy -c copy -crf 50 output.mp4

The end result, however, is too big for me to drag into an external hard drive.

I also tried writing directly to the hard drive /Volumes/2TR/output.mp4 but the end result is the same - the file is too big, the operation fails.

I noticed that if I terminate the operation at any point, the output.mp4 file works perfectly, but that it's not the full video (perfect). If the video is one hour and I just want 30 minutes of it I can terminate the ffmpeg operation at that point.

So I'm wondering whether there's a way for ffmpeg to download the contents in two parts, output-part1.mp4 and output-part2.mp4?

Upvotes: 1

Views: 3911

Answers (1)

Gyan
Gyan

Reputation: 92968

Use the segment muxer for this.

ffmpeg -i 'https://....m3u8' -c copy -f segment -segment_time 1800 output-part%d.mp4

This will split the output into segments of (nearly) 1800 seconds.

(-bsf:a aac_adtstoasc is automatically inserted by ffmpeg for a few years now. Your ffmpeg is too old if it's required.)

Upvotes: 3

Related Questions