Converting audio

How to convert large batch of audios ?


sudo apt-get install lame avconv
man lame                           # then search for parameters via "/{param}". ex: /-m


  • cbr: constant bit rate.
  • abr: average bit rate.
  • vbr: variable bit rate.

For more, see man lame.


mkdir -p ./new/                     # create folder, if not existing (-p)
file="./dir/audio-0a6f36g.flac"     # path to .flac file into varible "$file"
avconv -i "$file" 2>1               # print out metadata of $file, for some formats only

Simple batch format conversion

for file in ./flac/*.flac
  key=$(basename "$file" .flac).mp3                                 # name of the file minus .flac, plus .mp3 
  lame --abr 24    -m m -h --resample 22.05 "$file" "./new/$key";

Metadata-based format conversion

This example works on SWAC recorder audio files having the SWAC_TEXT metadata field. In this exemple, we assume a folder with file audio-0a6f36g.flac and metadata SWAC_TEXT : 很.

for file in ./flac/*.flac
  key=$(avconv -i "$file" 2>&1 | sed -ne 's/.*SWAC_TEXT *: //p')                 # print metadata, assign SWAC_TEXT's value to variable.
  lame --abr 24    -m m -h --resample 22.05 "$file" "./new-24k/cmn-$key.mp3";    # ex: cmn-很.mp3 (24k abr)
  lame --cbr -b 96 -m m -h --resample 22.05 "$file" "./new-96k/cmn-$key.mp3";    # ex: cmn-很.mp3 (96k cbr)

See also

Lingua Libre codes
Audio files Convert files formatsDenoise filesRename and mass rename
Bots Help:Bots
MediaWiki MediaWiki:Common.jsGadget-RecentNonAudio.js
Datasets Download datasets
Web integration Help:Embed audio in HTML