Search code examples
audiodirectshowlive-streamingtimestampmpeg-2

setting timestamps for audio samples in directshow graph


I am developing a directshow audio decoder filter, to decode AC3 audio. the filter is used in a live graph, decoding TS multicast. the demuxer (mainconcept) provides me with the audio data demuxed, but does not provide timestamps for the sample.

how can I get/compute the correct timestamp of the audio?


Solution

  • Each AC-3 frame embeds data for 6 * 256 samples. Sampling rate can be 32 kHz, 44.1 kHz or 48 kHz (as defined by AC-3 specification Digital Audio Compression Standard (AC-3, E-AC-3)). The frames themselves do not carry timestamps, so you needs to assume continuous stream and increment time stamps respectively. As you mentioned the source is live, you might need to re-adjust time stamps on data starvation.

    Each AC-3 frame is of fixed length (which you can identify from bitstream header), so you might also be checking if demultiplexer is giving you a single AC-3 frame or a few in a batch.