开发者

split video (avi/h264) on keyframe

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.

  1. 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 in man 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.

  2. 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:

  1. What is the best way to fix the index of an avi "inline" so that every tool can again work as expected with it?

  2. How can i split at the keyframes? Is there an mencoder-option for this?

  3. Are Keyframes coming in a frequency? How to find out this frequency? (So with a bit of math it should be possible to开发者_StackOverflow中文版 calculate the next keyframe and cut there)

  4. 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!


https://spreadsheets.google.com/ccc?key=0AjWmZ0umsuZHdHNzZVhuMTkxTHdYbUdCQzF3cE51Snc&hl=en lists the various options available for splitting accurately.


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.

ffmpeg -i input.avi -g 1 -vcodec copy -acodec copy out.avi

Then multiple splits (with FFMPEG) :

ffmpeg -i input.avi -ss 00:00:10 -t 00:00:30 out1.avi -ss 00:00:35 -t 00:00:30 out2.avi

Some more options to try:

x264 Mapping FFMPEG encoding in linux

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜