[FFmpeg-user] Noticed TimeStamp Issue When Muxing Raw h.264 into MKV

luke wilson lukec.wilson86 at gmail.com
Wed Feb 29 22:36:05 CET 2012

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

I don't think this is a perfect science but if you use libx264 and ffmpeg to
encode the raw h264 file I think it should be close enough that playback
on directshow will not be the wiser (it works for me). I think you might
be doing something like this for mp4 muxing.

Please let me know if I am misunderstanding something. If I'm not mis-
understanding something let me know if you would like me to build this out
for the community. FFMPEG has helped me out a lot so I would like to
give back to the community if possible.

"[matroska @ 01386340] Can't write packet with unknown timestamp
av_interleaved_write_frame(): Invalid argument"


More information about the ffmpeg-user mailing list