When you like to listen to a lot of Podcasts, lectures or audio books for instance, and you want to carry with you as much of it as you can then the opus audio codec is something you might be interested in. I rarely use this term but here it can be applied: The results blew my mind. It's astonishing how much audio you can pack on a mobile device with severe capacity limits.
I just converted this:
none 162 Files mp3, 44100 Hz, mono, s16p, 129 kb/s Total Length: 6d 14h 47min 49 Total Size: 9.05 GB
From 9.05 GB
to 555 MB
and am content with the results.
Please consider that this is a conversion from mp3 as source. Yes, that's right, I went from 128k
mp3 to 6k
opus and a weeks worth of audio is reduced to half a gig, and it has been converted from an unfavourable source. Though this is my personal hardcore setting, in my research I found out that you almost can't go wrong with 16k
, no matter how bad the source.
What is Opus?
In their own words: > Opus is a totally open, royalty-free, highly versatile audio codec. Opus is unmatched for interactive speech and music transmission over the Internet, but is also intended for storage and streaming applications. It is standardized by the Internet Engineering Task Force (IETF) as RFC 6716 which incorporated technology from Skype’s SILK codec and Xiph.Org’s CELT codec.
https://www.opus-codec.orghttps://en.wikipedia.org/wiki/Opus_%28audio_format%29
Comparison Chart Between MP3, AAC HE and Opus
Length | uncompressed | Codec | Bitrate | compressed | Factor |
---|---|---|---|---|---|
24 h | 14.88 GB | MP3 | 128k | 1382.4 | 11 |
24 h | 14.88 GB | AAC HE | 64k | 691.2 MB | 22 |
24 h | 14.88 GB | Opus | 16k | 172.8 MB | 86 |
24 h | 14.88 GB | Opus | 6k | 64.8 MB | 233 |
7 d | 104 GB | MP3 | 128k | 9.7 GB | 11 |
7 d | 104 GB | AAC HE | 64k | 4.8 GB | 22 |
7 d | 104 GB | Opus | 16k | 1.2 GB | 86 |
7 d | 104 GB | Opus | 6k | 0.5 GB | 233 |
30 d | 446 GB | MP3 | 128k | 41.5 GB | 11 |
30 d | 446 GB | AAC HE | 64k | 20.7 GB | 22 |
30 d | 446 GB | Opus | 16k | 5.2 GB | 86 |
30 d | 446 GB | Opus | 6k | 1.9 GB | 233 |
365 d | 5.4 TB | MP3 | 128k | 504.6 GB | 11 |
365 d | 5.4 TB | AAC HE | 64k | 252.3 GB | 22 |
365 d | 5.4 TB | Opus | 16k | 63.1 GB | 86 |
365 d | 5.4 TB | Opus | 6k | 23.6 GB | 233 |
Bitrate Calculator
Bitrate | kbit/s |
Length | s |
Filesize | MB |
Please note that opus uses VBR (it can be tweaked to CBR, which I do not recommend after seeing the results). Therefore final file size close but varies.
The Conversion Command
You can almost do no wrong with 16k
. In my experience even heavily compressed, bad sounding sources result in nearly as good quality as the source.
bash ffmpeg -i <input.file> -acodec libopus -b:a 16k <output.opus>
When the source files are of higher quality you still get impressive results with 6k
, which is the absolute minimum setting opus offers, but you can definitely hear the impact this massive compression brings along with it.
I personally use 6k bitrate compression even if the source is of minor quality, because I prefer having more in a tighter space with less quality, than having less with higher quality. That's the decision you have to make for yourself.
This is the hardcore setting I use:
bash ffmpeg -i <input.file> -acodec libopus -b:a 6k -application voip output.opus
Conversion Options
By default the options for libopus are solid. For the purpose of extreme size reduction we lower the bitrate. Then we optimize for speech recognition with the application
option in our particular case.
application (N.A.) Set intended application type. Valid options are listed below:
- voip -> Favor improved speech intelligibility.
- audio -> Favor faithfulness to the input (the default).
- lowdelay -> Restrict to only the lowest delay modes.
Handle Multiple Files Simultaneously
bash for f in *; do ffmpeg -n -i "$f" -acodec libopus -b:a 16k -application voip "encoded_"${f}".opus"; done
This command iterates through all files in the working directory and converts them into the opus format. The rendered files are stored in the same directory having the same name as the original files with a prefixed encoded_
. The Opus codec operates only single threaded.
Speed Things Up with Multithreading
Opus doesn't support multithreading and encodes are assigned to a single CPU core but you can parallelize the encoding process with the following bash commands.
bash bash -c 'ffmpeg_pids=(); for f in *; do ffmpeg -n -i "$f" -acodec libopus -b:a 16k -application voip encoded_"${f}".opus & ffmpeg_pids+=("$!"); done; wait "${ffmpeg_pids[@]}"'
bash # -P8 indicates Number of threads (of 4 core i7 in this case) find . -name "*.mp3" -print0 | xargs -0 -P8 -n1 -I {} ffmpeg -i {} -acodec libopus {}.opus
The first command will convert all files in the working directory simultaneously. And the second command converts as much as threads as are assigned but not more than that. The second command should be better when there are many files in the working directory.
Or use gnu parallel.
Opus Media Players for iOS
At least VLC does it.
Final Notes
I know, a lot of people will disagree with me on the 6k
setting. In this case please simply use 16k
.
System Setup and Tools Used:
- FFmpeg (3.2.2) with libopus and libfdk-aac enabled