I like to listen to audiobooks on my older phone. They can get quite large so I thought I would try to transcode (change their encoding format) from the older MP3 to the newer Opus
Opus has a useful setting to encode voice-optimized encoding for voice-over-IP applications. Audiobooks are only someone speaking so this is a perfect application for this setting
I downloaded Don Quixote from LibreVox the free public domain audiobooks as a test file.
It comes in several files. The command line to transcode a single file looks like this:
ffmpeg -i <INPUT_FILE> -c:a libopus -b:a 32k -vbr on -compression_level 10 -threads 0 -application voip <OUTPUT_FILE>
This resulted in a 50% reduction in file size on a single file (22M to 11M). On my in-ear exercise headphones where I listen to audiobooks, the sound quality was the same, YMMV.
The following line will transcode all the files in the current directory in parallel using xargs:
find . -maxdepth 1 -type f -name "*.mp3" | xargs -i -P0 ffmpeg -i {} -c:a libopus -b:a 32k -vbr on -compression_level 10 -threads 0 -application voip {}.opus
You will need to rename your files to remove the “.mp3.” part of the name:
for file in *.opus; do mv "$file" "${file%.mp3.opus}.opus"; done