I use alexa audio tags a lot. I know that now audio tags support 24kHz audio files so tried converting my audio files from 16kHz. I used the provided command in the docs to do so:
ffmpeg -i <input-file> -ac 2 -codec:a libmp3lame -b:a 48k -ar 24000 <output-file.mp3>
But when I try to play this file, I get an invalid response error, saying: Error: The audio is of an unsupported bitrate 64000
. By looking into file details I clearly see, that bitrate is 48kbps and sample rate is 24kHz. I don't see any value where it would say 64 or anything close to it.
If I encode my file back to 16kHz it plays fine again.
It seems that there is a problem with this command, because if I encode my files using audacity, they work with 24kHz. I still would prefer to use ffmpeg, because I need to encode a lot of files.
I am asking, not about file format, format is correct. I need files in 24kHz sample rate and that is what causes issues. I saw another question about similar problem and others having the discussion there about sample rates, but no one was able to encode file to be 24kHz using ffmpeg.
Did anyone had any luck on encoding files to 24kHz using ffmpeg?
Thanks LordNeckbeard for the suggestion to use lame
instead of ffmpeg.
So in order to encode files and have them in 24kHz you can use this command:
lame -b48 --resample 24 input.mp3 output.mp3
Alexa doesn't complain about files encoded like this. Also as mentioned in the question, you can still use audacity, but I prefer to use CLI, because I always have to encode batch of files.
Still if anyone figures out how to do it with ffmpeg
please share it.
EDIT:
Thanks again to LordNeckbeard for the suggestion to add -write_xing 0
flag to ffmpeg
command, now it works too.
The command to achieve 24kHz audio files with ffmpeg
is:
ffmpeg -i input.mp3 -codec:a libmp3lame -ac 2 -ar 24000 -b:a 48k -write_xing 0 output.mp3