[FFmpeg-user] Noticed TimeStamp Issue When Muxing Raw h.264 into MKV
mike.scheutzow at alcatel-lucent.com
Wed Feb 29 23:00:01 CET 2012
luke wilson wrote:
> To Whomever,
> I hope I'm in the right place with this. Anyway I noticed that you can not
> mux a raw h.264 streams into MKV because of the lack of a TimeStamp.
> Correct me if I'm wrong but I believe this error(see error below) is due to
> raw h.264 streams not containing any specific timestamp information.
Yes, you are correct.
> If this is the case I believe I have a proof of concept for creating
> data for a MKV mux.
> Proof Of Concept:
> 1. Get FPS from (Annex E) VUI FPS = time_scale / num_unit_in_tick * 2
> (I know this isn't perfect but it gets it close enough)
> 2. Take stream within each given cluster in MKV and count frames
> (There are a few variations)
> 3. Create a TimeStamp for Segments based on frame count against FPS
Your algorithm will work for the simplest cases, but not for many others.
Generating timestamps for H264 is more difficult than I think you
realize, at least if you want to do it correctly. This is because H264
supports (almost) arbitrary frame reordering in the decoder.
Also, are you aware that h264 streams do not have to be Constant Frame Rate?
Please work on this if you're interested, but be aware that it's a hard
problem. You will need to parse deep into the bitstream to gather all
the info necessary to figure out the decoded frame order.
More information about the ffmpeg-user