I have an .ogg file (containing speech) with 192kbps quality that i'd like to reduce to 32kbps (to save space)
How can i do this?
So far i've tried this:
ffmpeg -i filename.ogg -ab 32k -f ogg new-filename.ogg
But i get this error:
[libvorbis @ 0x56157365ab60] encoder setup failed
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
Am i using the wrong command? Is there a better approach i can take to save space? Please note that i only have access to the 192kbps file (not the original)
Grateful for help!
There are two excellent choices here:
Details of both are below:
1. Adjust your FFmpeg command line...
The key issue is that FFmpeg will not automagically change the audio sampling rate to appropriately match your selected bitrate. But then FFmpeg usually does not do a lot of hand holding I guess!
Bear in mind that an Audio CD will normally have a sampling rate of 44100 Hz while simple telephony would normally have a sampling rate of slightly greater than 8000 Hz. So you have a choice to make for the best sampling rate for your 32k Ogg Vorbis audio. The following are some guidelines:
With this in mind my own testing suggests that you would be best to use a sampling rate of 22050 Hz, note that this should be perfectly adequate for speech, and thus your command line should be:
And this produced a quite reasonable outcome on my own setup...
2. Use FFmpeg to create a small file using libopus...
If you are perhaps not all that set on using Ogg Vorbis an excellent alternative is to use Opus, which in my tests shaved a reasonable number of kilobytes off each file in comparison to the Ogg Vorbis 32k encode. Try something like the following which has been tailored for your speech files:
You will be pleasantly surprised by both the resulting output file size and audio quality. I have included a link to a great HydrogenAudio resource in the 'References' which should guide to an even better command line for Opus...
References:
Speech encoding quality: The definitive HydrogenAudio page to guide Opus settings for speech.
15.8 libopus: FFmpeg options for use with libopus encoding. Note the
-application voip
setting that I used above and which does not have an equivalent with opusenc (unlike the other settings).This low bitrate is not supported with the default sampling rate of the file. You must specify a lower sampling rate before you can lower the bitrate. Add the option -ar 8000 for your option -b:a 32k to be accepted.