2021-02-25
There are various audio recorders on the market, you could have stumbled upon one of these or something similar:
Name, model | Specs | Notes |
---|---|---|
Victure, X5 | 8GB, 12h, 510mAh |
stylish and solid (glass+metal) |
Elegiant, CupGtdQWy | 8GB, 16h | bulky and simple design with very long recording time |
Pendrive recorder | 8GB | very cheap, fragile, buggy, small battery, decent recordind time |
some of them can record directly in MP3 format but this depletes the battery faster than the WAV one.
Using the WAV format produces a file not suitable as input of our beloved tools like lame
, oggenc
or opusenc
, we can use mplayer
to convert it to a suported format:
1 2 3 4 5 6 7 | apt install mplayer opus-tools # convert WAV file to a supported format mplayer -vo null -vc null -ao pcm:fast:file=in_ok.wav in.wav # compress the converted WAV file in OPUS opusenc --bitrate 24 in_ok.wav out.opus |
you can use the attached recorder2opus.rb
script that uses a named pipe file to avoid the creation of the converted WAV file.
Using the Victure X5 recorder with the lowest WAV quality I made some compression tests in MP3, OGG and OPUS and these are the results:
- File size at the same bitrate: MP3 > OGG > OPUS. So OPUS is the winner.
- A meaningful bandpass range for voice recordings is about 11kHz so we should use an OPUS bitrate between 24-28Kb/s (see reccommended settings). The audio quality remains high in the range 20-28Kb/s but below the 24Kb/s the file size increases. So 24Kb/s is the winner.
- Trying to downmix to MONO always gave a bigger file. So it is better to keep it STEREO.
Play an opus files in console with standard tools:
1 | opusdec --force-wav --quiet file.opus - | aplay |
Here is a bash script to convert any audio file to opus:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #!/bin/bash FNAME=$1 FIFO=/tmp/audio2opus.fifo if [ ! -f "$FNAME" ]; then echo "file [$FNAME] not found!" exit fi mkfifo $FIFO mplayer \ -really-quiet -vo null -vc null \ -ao pcm:fast:file=$FIFO \ -slave -input file=/dev/null "$FNAME" & sleep 1 opusenc --bitrate 24 --title "${FNAME%.*}" \ $FIFO "${FNAME%.*}.ogg" sleep 1 rm -f $FIFO |
Reference: xiph.org, Vorbis, Opus & Opus FAQ, Lame encoder, Mplayer