How do I convert an mp3 file to a file with the following characteristics?
single-channel (monaural)
little-endian
unheadered
16-bit signed
PCM
sampled at 16000 Hz
I have tried running this command:
ffmpeg -i audio16000.mp3 -ar 16000 -ac 1 audio16000.wav
When I checked the file with this command:
sox --i audio16000.wav
I got the following results:
Input File : 'audio16000.wav'
Channels : 1
Sample Rate : 16000
Precision : 16-bit
Duration : 00:05:30.98 = 5295744 samples ~ 24823.8 CDDA sectors
File Size : 10.6M
Bit Rate : 256k
Sample Encoding: 16-bit Signed Integer PCM
It doesn't say if it's little endian or if it's unheadered. I also thought only a raw file is unheadered, and that a wav file has a header, but instructions I'm reading tells me to use that ffmpeg command I used above.
Your goal is to convert to PCM (Pulse-Code Modulation), which is essentially a raw audio file. That's why you also need all the extra information about endianness, precision etc. There's no header that would tell you that, it's unheadered.
With your command, you converted the file instead to WAVE format, which by definition has a header defining the encoding.
What you meant is:
ffmpeg -i audio16000.mp3 -f s16le -ac 1 -ar 16000 audio16000.raw
-f s16le
- 16-bit little-endianac 1
- 1 channel-ar 16000
- 16khzWhat extension you use (PCM or RAW) is really up to you. When reading the file in, you will have to provide encoding yourself anyway.