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?

前端 未结 2 534
野的像风
野的像风 2021-02-05 09:43

I am trying to convert an mp3 file to the format expected by the audio tag in the Amazon Alexa SSML markup language as described here: https://developer.amazon.com/public/soluti

相关标签:
2条回答
  • 2021-02-05 10:15

    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.
    
    0 讨论(0)
  • 2021-02-05 10:25

    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:

    http://www.mp3-tech.org/programmer/frame_header.html

    https://en.wikipedia.org/wiki/MP3

    0 讨论(0)
提交回复
热议问题