ffmpeg mp3 encoder: how to set exactly 8.00 kbps bitrate

341 Views Asked by At

I want to produce constant-bitrate mp3 with bitrate 8.00kbps. I use this: ffmpeg -i q.wav -b:a 8k q.mp3

But,instead of creating 8.00 kbps mp3, it creates 8.40 kbps file (or 8.41 or like that), as soxi informs:

Channels : 1 Sample Rate : 8000 Precision : 16-bit Duration : 00:00:05.11 = 40896 samples ~ 383.4 CDDA sectors File Size : 5.37k Bit Rate : 8.41k Sample Encoding: MPEG audio (layer I, II or III)

But I need 8.00 bitrate! I can easily produce it with sox q.wav -C 8 q.sox.mp3 Bit Rate : 8.41k

How can I force ffmpeg produce mp3s with 8.00 k bitrate exactly?

1

There are 1 best solutions below

3
sw55555 On

should change sample rate to lower than 32000(availables: 22050 24000 16000 11025 12000 8000), sample format to s16(libmp3lame supported sample formats: s32p fltp s16p), and using CBR(with both minrate and maxrate the same) mode to compress, command is blow should do the trick:

ffmpeg -hide_banner -y -i q.wav -vn -c:a mp3 -minrate:a 8k -maxrate:a 8k -b:a 8k -sample_fmt s16p -bufsize 200K -ar 24000 o.mp3