PDA

View Full Version : XviD VFW not ending with a clean frame sequence


Moitah
16th December 2005, 16:56
When encoding with B-VOPs, it's not uncommon for XviD to encode the last frame as a B-VOP, where the future reference P-VOP is one of the frames the encoding application used to flush. This results in the AVI ending strangely, for example: the last frame in the AVI is a P-VOP with a timestamp of a few frames in the future, and the B-VOPs that belong before it in display order are missing.

I fixed this myself a while back for 1.0.3 by storing the frame count when encoding starts (in 'compress_frames_info', store the value in icf->lFrameCount). Then during encoding (in 'compress') if the current frame number is >= last frame - 1, force it to be a P-VOP (frame.type = XVID_TYPE_PVOP). There is probably a better way to do this, but I just wanted to give an example of how it could be done.

I would love to see this fixed in the official releases of XviD, but it would probably be best to make it optional and disabled by default since some applications might not set lFrameCount. VirtualDub sets it, but AVS2AVI leaves it 0, and I'm not sure about others. I will gladly release a new version of AVS2AVI that sets lFrameCount if the XviD devs like this idea.

Moitah
26th December 2005, 07:42
I've figured out a workaround for the current versions of XviD. Add a new zone and make the frame number however many frames are in your video (i.e. if you were encoding a 3265 frame video, add a zone starting at frame 3265), and use the "Begin with keyframe" option.