简体   繁体   中英

Large HLS Stream to MP4 Clip using FFMPEG

I'm trying to create a clip from an HLS stream. The HLS stream is 8 hours long and the clip can be hours into the video. At most the clip is going to be 1 minute. Most similar answers on here convert the entire video to an mp4 which will take a very long time. Here's what I have so far:

ffmpeg -live_start_index 0 -ss 05:22:19.82667 -i https://example.com/main.m3u8 -t 00:00:55.65625 output.mp4

I like this implementation so far because ffmpeg seeks to the desired position in the playlist 5 hours into the video before it starts pulling down segments.

The problem with this is that I've noticed oftentimes the first few seconds of video is paused (my guess because ffmpeg sees a keyframe only every 6 seconds). Any help would be much appreciated!

Alright I ended up figuring this one out myself. I ended up utilizing both slow seeking and fast seeking:

ffmpeg -live_start_index 0 -ss 05:22:19.82667 -i https://example.com/main.m3u8 -ss 00:08:00.00 -t 00:00:55.65625 output.mp4

This allows me to quickly start at the position I want to seek at (minus a few seconds to account for keyframes) and then slow seek to the exact position I want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM