WAV file header for A-Law and mu-law - audio

Can some one tell me the WAV file header information for A-Law and Mu-Law?

In short, the WAVE format is a RIFF specification for mutlimedia files, which uses "chunks" to store data. Similar to a type-length-value representation, each chunk contains information about its own type and length (the fields SubChunkID and SubChunkSize) before the rest of the data.The information about the audio compression is stored in the "fmt" chunk.
Read this and this for more information.

Related

How to collect EVS codec from pcap file

I have several pcap files which captured by wireshark.
I collected that data from pcap file, payload data.
and saved it as file.
I tried to convert it to pcm data with this link
https://github.com/ToughmanL/EVS_CODEC
but it seems the data I collected is not EVS format.
please let me know how to get EVS codec from pcap file.
My understanding is that Stack Overflow is for programming questions, so here is an answer based on existing / example source code. First, in your screen cap Wireshark has found a commonly used form of EVS; the 61 byte packet payload length matches the EVS spec for 24400 bps primary mode, using compact format, which means (i) no ToC header byte in the payload, and (ii) only the payload size determines the bitrate. Second, to feed that to the 3GPP decoder you have to create a file with a MIME header and format, which is needed by the 3GPP reference program.
x86_mediatest.cpp (under the mediaTest folder in the Docker containers here) does this - it reads a pcap record-by-record, pulls out RTP payloads and writes them to a .cod file (coded format), including the MIME header. Running the 3GPP program on that file, with appropriate command line options then gives a PCM raw audio file you can convert to wav using sox, Audacity, Hypersignal, etc.
In x86_mediaTest.cpp, look for "if (pcap_extract) {". Also note the comment "If pcap RTP payloads are in CH (Compact Header) format, they are converted to FH (Header-Full) format by adding a ToC payload header byte". Which may explain why in your case, if you directly copied the compact header format payloads and fed them to the 3GPP decoder, it didn't work.
There is also a mediaMin program that will take the pcap on the command line and do the whole thing, generating a .wav file. You can use that for comparison and audio quality testing vs your code.
Disclaimer: I work for the company that created the mediaTest and mediaMin tools

MPEG Transport Stream Audio data information

I am writing a code to extract AAC audio data from mpeg ts stream. I want to get stream properties like sampling frequency, number of channels, Audio type, Audio profile type etc. from Transport stream, without decoding the actual data. How much of the information will be available from stream?
Also I want to know is there any way to find the total duration of the stream without actually finding the last PTS value in the file
Thanks
AAC frames packed in TS use ADTS headers. Its 7 (or 9) bytes, and very easy to parse. ADTS header format is documented well online.

Distinguish between PCM and BWF file format?

How can we distinguish between PCM and BWF format?
Is it necessary for BWF to have "bext" header?
I have some streams that don't have "bext" header but contains "JUNK" header... Are these files BWF files?
Thanks you.
The JUNK chunk is reserved space to allow a BWF file to be converted into an RF64 file on the fly if the size goes over 4GB. The JUNK chunk is the same size as a ds64 chunk, and will be replaced with a ds64 chunk if the conversion to RF64 is needed. Read more about it here.
My reading of the BWF spec is that you have to have a bext chunk for it to be a BWF.
As far as I know, a broadcast wave file will have the 'bext' header extension.
If a file does not have the 'bext' header extension, it will be a normal WAV/AIFF or whatever file.
Broadcast wave headers are used especially if you want to give a file more information about itself in the header which isn't to be seen immediately from its name.
For playing back, this info isn't necessary to know. Just if you want to show or search the meta information somehow.
PCM isn't a file format. All files that handle uncompressed data are PCM files.
Such as WAV/BWF, AIFF or SD2 for example.
With encoded files like MP3 or AAC you get the raw PCM values after decoding.
Yes. The 'bext' chunk is what distinguishes a BWF file from a wav file.
Some manufacturers actually use '.bwf' as a file extension but mostly the '.wav' extension will be used. It is only the presence of this chunk that makes the difference.
Other chunks can also be present and a well designed player will ignore chunks that it doesn't recognize.
Generally the 'data' chunk containing the audio data will be the last one in the file. However I have seen a few examples of other chunks, usually xml metadata, appearing after the 'data' chunk. This confuses some players.
For more information search for tech3285.pdf from the European Broadcasting Union website (tech.EBU.ch).

How to determine the codec of an audio file on Windows?

I need to find the codec of an audio file. How can I do this?
Do I need to write code to do this or is there a simpler way?
Please help me. If possible share helpful links.
The good old file utility will reveal lots of information about audio files, sometimes including the codec:
$ file X.wav
X.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 16000 Hz
#bhebsquines
"It is important to distinguish between a file format and an audio codec. A codec performs the encoding and decoding of the raw audio data while the data itself is stored in a file with a specific audio file format. Although most audio file formats support only one type of audio data (created with an audio coder), a multimedia container format (as Matroska or AVI) may support multiple types of audio and video data." - http://en.wikipedia.org/wiki/Audio_file_format
The application gspot does a good job of pulling codecs from audio and video files.
http://www.headbands.com/gspot/
run it and drag a file into the window. It will pull all of the data from there. Note that some audio files will not display a codec as they are made from "Raw" audio.
You can identify your codec by extenion name itself example file1audio.mp3 or fileaudio.avi, .mp3, .avi will be your file type or codec, you can use k-lite codec pack for your different type audio format. use this link http://www.free-codecs.com/download/k_lite_codec_pack.htm

Is the endianness of format params guaranteed in RIFF WAV files?

Is the endianness of format params guaranteed in RIFF WAV files? I have heard conflicting answers to this including references to a RIFX file format.
Yes.
If the file starts with RIFF, then it's little endian.
If it starts with FFIR or RIFX, then it's probably not.
Generally, supporting the WAV format means supporting RIFF files, although adding RIFX support should not prove difficult.
The AES31 specification for BWF (Broadcast Wave Format) references this specification for RIFF: http://www.tactilemedia.com/info/MCI_Control_Info.html
From this:
RIFF has a counterpart, RIFX, that is
used to define RIFF file formats that
use the Motorola integer byte-ordering
format rather than the Intel format. A
RIFX file is the same as a RIFF file,
except that the first four bytes are
'RIFX' instead of 'RIFF', and integer
byte ordering is represented in
Motorola format.
The KVR article you reference refers to the author's incorrect usage of int* on big-endian systems (Motorola PPC), which will retrieve byte-swapped values. Care is always necessary to handle byte-swapping correctly when writing cross-endian code.
If the zeroth byte of the file on disk is 'R', and the 3rd is 'F', you can be certain that the rest of the contents will be stored little endian.
RIFX is not widely used. Most big-endian RIFF implementations swap bytes to disk, and generate correct RIFF files.

Resources