-1

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?

R. Vait
  • 918
  • 2
  • 7
  • 20
  • Possible duplicate of [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?](https://stackoverflow.com/questions/34583224/what-is-the-right-command-to-convert-an-mp3-file-to-the-required-codec-version) – szatmary Nov 26 '18 at 14:11
  • That question asks about format MPEG. I ask about bit rate, these are two separate issues, even though I see that some users discussed this there, but still, question was about different thing and there was no answer given regarding bit rate. – R. Vait Nov 26 '18 at 14:19
  • 1
    I'm not exactly sure why you want to resample from a 16kHz source to 24kHz. Anyway, try adding the `-abr 1` output option. For such low bitrates using LAME's average bitrate mode [is the recommended method according to hydrogenaud.io](http://wiki.hydrogenaud.io/index.php?title=LAME#Recommended_encoder_settings). If that doesn't work try using `lame` itself. – llogan Nov 26 '18 at 18:37
  • Thanks, `lame` worked. How I didn't think of trying it. – R. Vait Nov 27 '18 at 12:04
  • 1
    @R.Vait Also try the `-write_xing 0` output option in `ffmpeg`, although I doubt it will help in this case. – llogan Nov 27 '18 at 19:28
  • Thanks. When I added this command, it started working with `ffmpeg` too. Could you briefly explain what does it do? – R. Vait Nov 28 '18 at 09:40
  • 1
    If you use @LordNeckbeard I will be notified of your replies (this isn't necessary in all situations so refer to [help] for more info). I'm not sure of the technical reasons for that behavior: never got motivated to looked into it, but there are some related bug reports: [#2697](https://trac.ffmpeg.org/ticket/2697), [#3599](https://trac.ffmpeg.org/ticket/3599), [#4214](https://trac.ffmpeg.org/ticket/4214). – llogan Nov 28 '18 at 19:28

1 Answers1

1

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
R. Vait
  • 918
  • 2
  • 7
  • 20