Codec and setting for lowest bitrate ffmpeg output

1

I need to convert my input audio file to the lowest possible size to transfer it over a radio transmitter.

Now with the AAC codec and MP3 format I used 8kbps for bit rate, 16 kHz for sampling rate and 1 channel, and my output data is about 3kb per second.

But when I change the sample rate to 8 kHz or a lower bit rate, I get an error saying that the codec does not support this setting.

Is there a setting to get lower rate for the output file?

P.S: Because I'm working on Android, it's hard to install codecs, so I must use the ffmpeg default codecs.

Update:

i used opus command line now this is my command:

ffmpeg -i a.mp3 -vn -c:a libopus -ac 1 -ar 8000 -b:a 500 -vbr constrained -compression_level 0 -application lowdelay output22.mkv

and the result is

Input #0, mp3, from 'a.mp3':
  Metadata:
    title           : Salam (myahangha.ir)
    artist          : Sogand
    album           : Javooni
    comment         : ..:: myahangha.ir ::..
    genre           : 2019
    date            : 2019
  Duration: 00:03:15.24, start: 0.000000, bitrate: 324 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 320 kb/s
    Stream #0:1: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 500x500 [SAR 72:72 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
    Metadata:
      title           : Radio Javan - Javooni.jpg
      comment         : Other
Stream mapping:
  Stream #0:0 -> #0:0 (mp3 (mp3float) -> opus (libopus))
Press [q] to stop, [?] for help
[libopus @ 0000028b84d9e200] Bitrate 500 is extremely low, maybe you mean 500k
The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s
Output #0, matroska, to 'output24.mkv':
  Metadata:
    title           : Salam (myahangha.ir)
    artist          : Sogand
    album           : Javooni
    comment         : ..:: myahangha.ir ::..
    genre           : 2019
    date            : 2019
    encoder         : Lavf58.27.102
    Stream #0:0: Audio: opus (libopus) ([255][255][255][255] / 0xFFFFFFFF), 8000 Hz, mono, flt, 0 kb/s
    Metadata:
      encoder         : Lavc58.51.100 libopus
size=     116kB time=00:03:15.25 bitrate=   4.9kbits/s speed= 396x
video:0kB audio:57kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 103.282921%

it seems opus dont accept bit rates lower then 4.9kbps :(

audio
ffmpeg
android
mp3
asked on Super User Apr 7, 2019 by peiman F. • edited Apr 17, 2019 by peiman F.

1 Answer

4

AAC or MP3 are not the best choice of codecs for ultra-low bandwidth transmissions. Use a proper speech codec with higher efficiency.

Opus is the best option. It is available in FFmpeg through libopus. In fact, Opus is not just made for speech; it offers hybrid encoding for both speech and music.

Example:

ffmpeg -i <input> -c:a libopus -ac 1 -ar 16000 -b:a 8K -vbr constrained out.opus

Here, -ac sets the output to mono, -ar sets the sampling rate to 16 kHz, and -b:a sets the bitrate to 8 kBit/s. The constrained variable bitrate mode is used here. In principle, it's not strictly necessary to downsample and downmix to mono with ffmpeg, as that is something libopus will do on its own to reach the specified bitrate target.

Some further recommendations are given here. Note that with Opus, 6–8 kBit/s is usable range for (mono, lower sample rate) speech, but not for music.

You'll find an interesting comparison of different codecs and their bitrate/quality curve on the Opus website:

I should add that this figure is an indication only; it's compiled from different test results and anecdotal knowledge.

answered on Super User Apr 7, 2019 by slhck • edited Apr 7, 2019 by slhck

User contributions licensed under CC BY-SA 3.0