views:

193

answers:

1

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 sut 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 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!

A: 

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. -sameq will ensure no bitrate loss during the split.

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

Then multiple splits (with FFMPEG) :

ffmpeg -i input.avi -sameq -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

B00MER
As an input I;m stuck with an AVI-Container. I get it from an network-cam, this is the only option. As an output format I'd like to go with h264/mp4 anyways.I will try avidemux (have to RTFM) for repairing the index and then ffmpeg -g 1 - however I'm wondering how this will increase my file size. My Input video already has about 10GB.Thank you very much for your input!
m.sr