简体   繁体   English

大 HLS Stream 到 MP4 剪辑使用 FFMPEG

[英]Large HLS Stream to MP4 Clip using FFMPEG

I'm trying to create a clip from an HLS stream.我正在尝试从 HLS stream 创建一个剪辑。 The HLS stream is 8 hours long and the clip can be hours into the video. HLS stream 时长为 8 小时,视频可能长达数小时。 At most the clip is going to be 1 minute.剪辑最多为 1 分钟。 Most similar answers on here convert the entire video to an mp4 which will take a very long time.此处最相似的答案将整个视频转换为 mp4,这将需要很长时间。 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.到目前为止,我喜欢这个实现,因为 ffmpeg 在视频开始拉下片段之前 5 小时在播放列表中寻找所需的 position。

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).问题是我注意到视频的前几秒经常被暂停(我的猜测是因为 ffmpeg 每 6 秒才看到一个关键帧)。 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.这使我可以快速从我想要寻找的 position 开始(减去几秒钟以考虑关键帧),然后缓慢寻找到我想要的确切 position。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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