在关键帧上分割视频 (avi/h264)
你好。
我有一个很大的视频文件。 ffmpeg
、tcprobe
和其他工具说,它是 AVI 容器中的 h264 流。
现在我想从视频中剪出小块。
问题:视频接缝的索引已损坏/损坏。我通过 mplayer -forceidx -saveidx
修复了这个问题<大视频文件>。这里的问题是,我现在陷入了 mplayer/mencoder 的困境,它可以通过 -loadidx
使用此索引文件。我已尝试按照man aviindex
中所述更正索引 (mplayer -frames 0 -saveidx mpidxbroken.avi ; aviindex -i mpidx -o tcindex ; avmerge -x tcindex -ibroken.avi -ofixed.avi
),但这并没有修复我的视频 - 这意味着我测试过的大多数工具都无法在视频文件中搜索。问题:我通过以下命令剪切了部分视频:
mencoder -loadidx in.idx -ss 8578 -endpos 20 -oac faac -ovc x264 -sws 9 -lavfopts format=mp4 -x264encopts
。现在的问题是,有些视频一开始就损坏了。我认为这是因为事实上,我不一定在关键帧处剪切。; -of lavf -vf scale=800:-10,harddup in.avi -o out.mp4
问题:
修复 avi“内联”索引以便每个工具都能再次按预期工作的最佳方法是什么?
如何在关键帧处分割?有mencoder选项吗?
关键帧是否按频率出现?如何找出这个频率呢? (因此,通过一些数学计算,应该可以计算下一个关键帧并在那里剪切)
是否有其他完全不同的方式来分割这部电影?手工制作是没有选择的,我必须剪掉 1000 多个块...
非常感谢!
Hallo.
I have a big video file. ffmpeg
, tcprobe
and other tool say, it is an h264-stream in an AVI-container.
Now i'd like to cut out small chunks form the video.
Problem: The index of the video seam corrupted/destroyed. I kind of fixed this via
mplayer -forceidx -saveidx <IndexFile> <BigVideoFile>
. The Problem here is, that I'm now stuck with mplayer/mencoder which can use this index file via-loadidx <IndexFile>
. I have tried correcting the index like described inman aviindex
(mplayer -frames 0 -saveidx mpidx broken.avi ; aviindex -i mpidx -o tcindex ; avimerge -x tcindex -i broken.avi -o fixed.avi
), but this didn't fix my video - meaning that most tools i've tested couldn't search in the video file.Problem: I cut out parts of the video via following command:
mencoder -loadidx in.idx -ss 8578 -endpos 20 -oac faac -ovc x264 -sws 9 -lavfopts format=mp4 -x264encopts <LotsOfOpts> -of lavf -vf scale=800:-10,harddup in.avi -o out.mp4
. Now here the problem is, that some videos are corrupted at the beginning. I think this is because the fact, that i do not necessarily cut at keyframe.
Questions:
What is the best way to fix the index of an avi "inline" so that every tool can again work as expected with it?
How can i split at the keyframes? Is there an mencoder-option for this?
Are Keyframes coming in a frequency? How to find out this frequency? (So with a bit of math it should be possible to calculate the next keyframe and cut there)
Is ther perhaps some completely other way to split this movie? Doing it by hand is no option, i've to cut out 1000+ chunks ...
Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
https://spreadsheets.google.com/ccc?key=0AjWmZ0umsuZHdHNzZVhuMTkxTHdYbUdCQzF3cE51 Snc&hl=en 列出了可用于精确拆分的各种选项。
https://spreadsheets.google.com/ccc?key=0AjWmZ0umsuZHdHNzZVhuMTkxTHdYbUdCQzF3cE51Snc&hl=en lists the various options available for splitting accurately.
在执行任何操作之前,我会尝试使用 avidemux 修复文件。使用基于 MP4 的容器也可能比 AVI 获得更好的结果。
至于确保您指定的间隔在关键帧处正确,我建议在使用下面的分割之前使用 FFMPEG 进行编码:
-g 1
选项,以确保每个帧实际上都是关键帧。 FFMPEG 将关键帧称为 GOP 或图片组。然后多重分割(使用 FFMPEG):
尝试更多选项:
x264 映射 FFMPEG 编码在Linux中
I would attempt to use avidemux to repair the file before doing anything. You may also have better results using an MP4 Based Container than AVI.
As for ensuring your specified intervals are right at the keyframe, I would suggest encoding with FFMPEG with the:
-g 1
option before using the split below to ensure every frame is in fact a keyframe. FFMPEG refers to keyframs as GOP or Groups of Pictures instead.Then multiple splits (with FFMPEG) :
Some more options to try:
x264 Mapping FFMPEG encoding in linux