Log in

View Full Version : AC3 in TS


GaveUp
19th August 2004, 22:36
How is a AC3 stored in a TS? I am trying to demux out the ac3 from some sample streams I have and the output of my code always differs from other demultiplexers. Comparing a good demux and mine shows a few thousand bytes of extra data at the beginning and then extra data elsewhere in the stream. I thought maybe the demux starts only with the first ac3 syncword that's found but that appears not to be the case. For reference all my code does right now is copy the databytes of a TS packet to the output file. If someone could give me some info as to what I'm doing wrong I'd appreciate it.

unixfs
19th August 2004, 22:47
usually it's stored the same way as in dvd: in pes streams with 0xbd
stream_id and with substream_id >= 0x80.
You only have to remember that
1) pes streams are fragmented because of the 188 bytes TS packetization,
so you have to reassemble the pes payloads and discard the data in excessive
2) in DVB (e.g. Pro-7) when pes_aligned is set and the pes payload begins
directly with 0x0B77 (without the substream_id); in this case in the
PMT the corresponding audio stream must contains stream_tag=0x06 and one of the descriptors must contain stream_type=0x6a

GaveUp
19th August 2004, 23:13
I am using the same code as I wrote, and successfully tested, for video. It removes PES payload and all that. Debugging though, I set it to print whenever it found a new PES packet (based on the flag in the TS packet) and it never did. Also, since I compared the output vs that of bbdmux, dvd2avi, etc and it appears as if the first dozen or so TS packets of the audio pid are just ignored. Also, none of the outputed ac3's start with any of the id's you've mentioned or I've seen mentioned in the specs.

unixfs
19th August 2004, 23:24
can you upload a short sample somewhere accessible, please?