What is the right command to convert an mp3 file to the required codec version (MPEG version 2) and bit rate (48 kbps) for Amazon Alexa SSML?

Its a little confusing, and frankly a little odd that amazon requires this. mp3 files can be mpeg1 or mpeg2 or mpeg-2.5 (non standard, but widely supported). For this purpose, the main differences between the versions are bitrate and sample rate. Amazon requires 48kbps (which is supported in all mpeg versions). Next, mpeg-2 only supports sample rates of 22050 Hz, 24000 Hz, and 16000 Hz. So resampling to one of those frequencies should force ffmpeg to MPEG-2 layer 3.

ffmpeg -y -i input.mp3 -ar 16000 -ab 48k -codec:a libmp3lame -ac 1 output.mp3

more info here and here:



Here's what I had to do to get it working:

ffmpeg -i input.mp3 -b:a 48k -ar 16000 output.mp3

Here's the output when I play it with mpg123:

$ mpg123 output.mp3 
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
        version 1.22.4; written and copyright by Michael Hipp and others
        free software (LGPL) without any warranty but with best wishes

Playing MPEG stream 1 of 1: output.mp3 ...

MPEG 2.0 layer III, VBR, 16000 Hz joint-stereo

[0:02] Decoding of output.mp3 finished.