Log in

View Full Version : dev question: how to create "empty frame" bitstream on the fly?


madshi
29th December 2008, 19:01
Hey devs,

I've the following problem: My h264 demuxing tool (eac3to) is supposed to demux the video stream in such a way that the demuxed raw bitstream file plays similar to the original container it was stored in. No problem with clean source files. But I have a problem if e.g. a TS source file is corrupted. In that case some video frames might be missing. I can detect missing frames by checking the container's timestamps. Now I'm looking for an easy way to add "dummy" frames back into the demuxed video bitstream, so that the raw bitstream doesn't "skip" frames at the corruption point. This is important, because without it audio sync would be lost and time consuming resync would be necessary...

With VC-1 in addition to the standard frame types "I, P, B, BI" there is a "Skipped" frame type, which is (IIRC) just one byte long and which simply says: "Repeat the previous frame". Is there anything similar available in h264 bitstream? That would make things VERY easy for me. If not, how difficult would it be to create the necessary bitstream for a new empty "dummy" frame on the fly?

Thanks!

P.S: Just for the record: I've some experiencing with parsing h264 bitstream to extract some information, but I'm far from being a h264 expert...

akupenguin
31st December 2008, 04:58
h264 doesn't have a special frame type for skips, but you can make a non-referenced P-frame containing only skip macroblocks and insert it wherever a frame was dropped. You still need the right number of macroblocks, and some slice header fields need to be set consistent with the pps.

madshi
31st December 2008, 12:13
I guess setting the slice header fields shouldn't be too much of a problem, since I've already code to rewrite these, anyway. But I've never touched macroblocks yet. Do you have any hints to get me started on how to find out how many macroblocks I have to use?

An alternative idea: Do you think it would sense for me to always keep the last valid P-frame in memory and then to simply manipulate it in such a way that it is non-referencing and has only skip macroblocks? I guess that would be easier than recreating a whole new frame from the ground up? Or do you think recreating a whole new frame is easy enough? I'm not sure right now how complex it would be.

Thanks for your help!