When preparing a compilation for a rehearsal, after you have decided on one of the audio formats supported by Replayer, you might need convert all those files to the target audio format. Here's how to do that.

Using FFmpeg as converter

FFmpeg is a multi-purpose conversion tool, which is available as packages or binaries on all major operating systems (Windows/Linux/Mac). It does have a CLI (Command Line Interface), which offers all the relevant options for the conversion.

The following example scripts scans all folders for WAV files, recursively, and converts each file into an MP3 file (or other format), using the compression options given. If you have another source file format just replace the search filter with the matching extension.

In the scripts, you can manually enable the compression variant(s) that best fit your playback scenario.

Linux (bash) script, for WAV to MP3

#! /bin/bash
# Convert all .wav files in this and all sub directories to .mp3
# See https://trac.ffmpeg.org/wiki/Encode/MP3 for bitrate options
# Enable the bitrate(s) that suits your need
# Optional: Delete .wav files after conversion

export IFS=$'\n';
time for song in $(find -type f -iname '*.wav' |sed 's!\.wav$!!');
do
  echo -n "$song.mp3"
  ffmpeg -i "$song.wav" -b:a 320k "$song-320k-CBR.mp3"
  ffmpeg -i "$song.wav" -q:a 0 "$song-220-260k-VBR.mp3"
  ffmpeg -i "$song.wav" -q:a 6 "$song-100-130k-VBR.mp3"
  ffmpeg -i "$song.wav" -q:a 9 "$song-45-85k-VBR.mp3"    
  #-i - input file
  #-b:a - Target audio bitrate. See ffmpeg docs for details
  #-q:a - Target quality. See ffmpeg docs for details
  # uncomment the next line to delete .wav after conversion.
  #rm "$song.wav";  
  echo -n " ";
done

Listing: bash script for bulk converting WAV files to MP3 files

Linux (bash) script, for WAV to AAC (.m4a)

#! /bin/bash
# Convert all .wav files in this and all sub directories to AAC (.m4a)
# See https://trac.ffmpeg.org/wiki/Encode/AAC for bitrate options
# Enable the bitrate(s) that suits your need
# Optional: Delete .wav files after conversion

export IFS=$'\n';
time for song in $(find -type f -iname '*.wav' |sed 's!\.wav$!!');
do
  echo -n "$song.m4a"
  ffmpeg -i $song.wav -c:a aac -b:a 320k "$song-320k-CBR.m4a"
  ffmpeg -i $song.wav -c:a aac -q:a 2 "$song-qa2-VBR.m4a"
  ffmpeg -i $song.wav -c:a aac -q:a 1 "$song-qa1-VBR.m4a"
  ffmpeg -i $song.wav -c:a aac -q:a 0.5 "$song-qa05-VBR.m4a"
  #-i - input file
  #-b:a - Target audio bitrate. See ffmpeg docs for details
  #-q:a - Target quality. See ffmpeg docs for details
  # uncomment the next line to delete .wav after conversion.
  #rm "$song.wav";  
  echo -n " ";
done

Listing: bash script for bulk converting WAV files to AAC files

Previous Post Next Post