Notes on using the mpeg-4 mux
The mpeg-4 file format includes an index which lists the time and location for each access unit (picture) in the file. To build this index, the mux filter needs to know both the timestamp of each access unit and also the boundaries of each access unit. The multiplexor does not analyse individual elementary stream structures, so it needs this information to be supplied correctly in the DirectShow IMediaSample properties:
- Set a timestamp on each access unit using IMediaSample::SetTime
- Each IMediaSample object should contain exactly one access unit.
- If the access units are too large to fit into a single buffer, you can split it access several buffers. In this case, set the timestamp only on the last buffer of the access unit. The mux will assume that the preceding buffers without timestamps are part of the same sample.
- If you are using B frames, so that your timestamps are not in presentation order, it's better if you can set the end time of the sample to indicate the correct duration. Many compressed streams in DirectShow have only the start time set correctly, with the end time being start+1: in this case, without the decode timestamp or a reliable frame duration, it is difficult to calculate the CTTS table correctly.
6 April 2009