Skip to content

Instantly share code, notes, and snippets.

@thibmaek
Created August 17, 2015 23:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thibmaek/0e29020541bd8a3f7c47 to your computer and use it in GitHub Desktop.
Save thibmaek/0e29020541bd8a3f7c47 to your computer and use it in GitHub Desktop.
Convert FLAC to AAC | MP3
function _audio() {
case $1 in
--mp3|*) local CODEC=libmp3lame;local FILENAME=mp3;;
--aac) local CODEC=libvo_aacenc;local FILENAME=aac;;
esac
case $2 in
256|*) local BITRATE=256k;;
320) local BITRATE=320k;;
esac
for FILE in *.flac; do
ffmpeg -i "$FILE" -c:a $CODEC -b:a $BITRATE "`basename "$FILE" .flac`.$FILENAME" || break;
done
}
@thibmaek
Copy link
Author

_audio

The quickest way to encode FLAC files to lossy formats using a simple I/O ffmpeg task.
You can install ffmpeg with brew install ffmpeg or sudo apt-get install ffmpeg

Options

  • --mp3: Encodes the input as MP3 using lame.
  • --aac: Encodes the input as AAC using libvo_aacenc. Due to the experimental nature of AAC encoding in ffmpeg this isn't really stable (no cover art e.g) and only to use if you really want it.
  • 256: Second option that you can pass trough, encodes as 256kbps.
  • 320: Same as above but 320kbps

Defaults

Just running _audio in a shell will output a 256kbps MP3. My personal preference is _audio --aac or audio 320

Disclaimer: this could probably be cleaner. Vars are scoped locally within the function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment