View Full Version : Getting number of channels in PCM
ipanema
10th May 2009, 12:44
According to the wikipedia page for AVCHD, the audio can be linear PCM with up to 7.1 channels.
I had thought that the audio payload would just be a dump of PCM sample values, but there must be a way of finding out the sample size and number of channels etc. Is there a header at the beginning of PCM data which contains this information (like there is with AC-3 format)?
tebasuna51
10th May 2009, 13:32
You need the PCM inside a container (m2ts if AVCHD, wav, vob, ...), if you extract the audio like PCM is only raw data without headers.
Only eac3to, with a method not always sure, can try detect the parameters: channels, bitdepth, samplerate and endian.
SeeMoreDigital
10th May 2009, 13:39
TSmuxer is able to provide the following: -
http://i43.tinypic.com/161i8hu.png
ipanema
10th May 2009, 14:27
Sorry I forgot to mention that I want to do this in source code rather than using a utility.
Many file types such as AVI and probably WAV have headers which contain this info - I think that's what your screenshot of tsRemuxer is reading. But I think that the m2ts files containing PCM do not have this info - does anyone know where this info is stored in m2ts files or how it might be calculated from the raw PCM data?
TinTime
10th May 2009, 16:04
Yes, the wav header contains this info. If you've just got raw pcm then the best you can do is use educated guesswork - e.g. if the size of the pcm data is a multiple of 18 then it's probably 5.1, 24 bit audio. Then you need to assume likely channel map, endian, and so on. I'm sure that the guesswork can be refined but it's still not ideal.
If you're reading an m2ts file though then I'm pretty sure the correct format is stored in there somewhere, but I don't know where I'm afraid. I think this would be the course to pursue though.
Sorry, I've just realised I've not been any help at all :)
tebasuna51
10th May 2009, 16:20
I found the same 4 bytes needed in pcm_for_TsMuxer inside the m2ts files.
Check the source code in Pcm2Tsmu (https://forum.doom9.org/showthread.php?p=1137225#post1137225)
Like I say you the standard pcm don't have headers.
ipanema
10th May 2009, 22:36
Thanks tebasuna51. Did you mean the 4 user_data bytes in the audio stream of the PMT ?
tebasuna51
11th May 2009, 00:11
I don't know the m2ts structure. Found only with hex editor.
See also: http://forum.doom9.org/showthread.php?p=1261736#post1261736
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.