Conversion between AMR (Adaptive Multi-rate Codec) file formats
Eric Woudenberg, Feb 2003
(eaw@connact.com)
Formats
There appear to be [at least] two file formats for AMR codec data. These are:
- ".AMR" Files stored in "AMR File Storage Format". This is
specified in draft-ietf-avt-rtp-amr-10.txt, Sec. 6.2, which is
included with the Ericsson AMR converter tool. (The draft is an early form of RFC
3267). These are handled by the Ericsson AMR tool, as well as by
Nokia Series 60 phones. They have a header of "#!AMR\n".
- ".COD" Files stored in "AMR Interface Format 2." This is specified in
3GPP TS 26.101, Appendix A. These
are coded and decoded by the
3GPP TS 26.104 floating point reference codec source package.
Tools
To aid development work with these two formats (and to clarify their
differences) I have written amrconv.py, a small Python program that converts
between the two formats. Here is the Usage message:
This program converts between:
.amr files [AMR File Storage Format (draft-ietf-avt-rtp-amr-10.txt, Sec. 6.2)]
and
.cod files [AMR Interface Format 2 (3GPP TS 26.101, Annex A)]
Usage: amrconv.py filename.ext
When .ext == '.amr' creates filename.ext.cod file
When .ext == '.cod' creates filename.ext.amr file
Differences
".AMR" files:
- Have a 6 byte header: "#!AMR\n".
- Take two nibbles (8 bits) to express the frame flags [Format:
"PTTTTVPP", where P is "Pad" (0), T is "Frame Type", and V is "Valid"].
- Pack the bits of the frame into bytes in big-endian
order, that is, the most significant bit (0x80) of each byte is
actually the first bit of the byte, the least significant bit (0x1) is the last bit.
".COD" files:
- Have no header.
- Require a single nibble to express the frame flags: "TTTT", which is the Frame Type field.
The actual speech frame bits begin directly after this, in the 2nd nibble of the first byte of
the frame.
-
Pack the bits of the frame into bytes in little-endian
order. This is the way programmers usually think of packing bits in bytes. The least significant bit is the first bit of the byte, followed by the 0x2 bit, the 0x4 bit, etc.
Other Convertors
A person named Xabi has a created a AMR <-> IFS converter (in perl).