如何使用 FFMPEG 分割视频,以便每个块都以关键帧开头? [英] How to split a video using FFMPEG so that each chunk starts with a key frame?

查看:52
本文介绍了如何使用 FFMPEG 分割视频,以便每个块都以关键帧开头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们需要将大型实时 WMV 视频源分成大小相同的小块.我们制作了一个可以很好地执行此操作的脚本,除了一件事:视频块不以关键帧开头,因此在播放大多数视频块时,它们不会显示任何图像,直到原始视频的关键帧最终出现到达.

We need to split a large live WMV video feed in small chunks all of the same size. We made a script that works fine doing this, except for one thing: the video chunks don't start with a key frame, so when playing most video chunks they don't display any image until a key frame from the original video is eventually reached.

有没有办法告诉ffmpeg让输出视频从关键帧开始?

Isn't there a way to tell ffmpeg to make the output video to start with a key frame?

这是我们的命令行现在的样子:

Here is how our command lines look right now:

ffmpeg.exe -i "C:	est.wmv" -ss 00:00:00 -t 00:00:05 -acodec copy -vcodec copy -async 1 -y  "0000.wmv"
ffmpeg.exe -i "C:	est.wmv" -ss 00:00:05 -t 00:00:05 -acodec copy -vcodec copy -async 1 -y  "0001.wmv"

等等...

推荐答案

FFMPEG 的最新版本包括一个新选项segment",它完全符合我的想法.

The latest builds of FFMPEG include a new option "segment" which does exactly what I think you need.

ffmpeg -i INPUT.mp4 -acodec copy -f segment -vcodec copy -reset_timestamps 1 -map 0 OUTPUT%d.mp4

这会生成一系列编号的输出文件,这些文件根据关键帧分成多个段.在我自己的测试中,它运行良好,尽管我没有使用它超过几分钟,而且只使用 MP4 格式.

This produces a series of numbered output files which are split into segments based on Key Frames. In my own testing, it's worked well, although I haven't used it on anything longer than a few minutes and only in MP4 format.

这篇关于如何使用 FFMPEG 分割视频,以便每个块都以关键帧开头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆