This is a cool thread, but I tend to prefer a quality-based variable bit rate mode (like x264's -crf option) with the -q flag. This way, the files that need it (mostly those with a higher dynamic range) will get a higher bitrate, whereas those that don't need it will use a lower bitrate. It ranges from 0 to 1, I've been using
Code:
neroAacEnc -if input.wav -q 0.5 outputfile.m4a
From here, a guide to the average (over a number of different files) bitrates of various VBRs as set by -q:
As for that script you found, Shantiq, I happen to have written a similar one recently that uses avprobe to gather metadata and should be more universal than using metaflac. The original thread is here, and that script should be used through nautilus-scripts. Here's a more versatile version for use on the command-line:
Code:
#!/bin/bash
#### Requires: avconv, neroAacEnc, NeroAacTag
#### Default VBR quality is 0.5
quality="0.5"
mode="q"
adv=
usage ()
{
echo "Usage: convert-to-m4a input.file <arguments>
By default, this uses a VBR mode with the neroAacEnc tag of -q 0.5
You can set a constant bit rate with -br <bitrate> OR -cbr <bitrate>
You can use any other neroAacEnc options by using -adv \"-option1 -option2\" - be sure to enclose the options in quotation marks!
Advanced options and details on the encoding modes can be found in the neroAacEnc readme.txt"
}
#### Parse command-line options
if [ $# = 0 ]; then
echo "No input file stated"
usage
exit
fi
while [ "$1" != "" ]; do
case "$1" in
-h ) usage
exit
;;
-q ) mode="q"
shift
quality="$1"
;;
-cbr ) mode="cbr"
shift
quality="$1"
;;
-br ) mode="br"
shift
quality="$1"
;;
-adv ) shift
adv="$1"
;;
* ) filename="$1"
;;
esac
shift
done
for f in "$filename"; do
#### Now grab some metadata
metadata=$(avprobe "$f" 2>&1)
title=$(echo "$metadata" | grep -i title | sed 's/.*: //')
artist=$(echo "$metadata" | grep -i artist .tempfile | sed 's/.*: //')
track=$(echo "$metadata" | grep -i track | sed 's/.*: //')
tracktotal=$(echo "$metadata" | grep -i tracktotal | sed 's/.*: //')
genre=$(echo "$metadata" | grep -i genre | sed 's/.*: //')
date=$(echo "$metadata" | grep -i date | sed 's/.*: //')
album=$(echo "$metadata" | grep -i album | sed 's/.*: //')
album_artist=$(echo "$metadata" | grep -i album_artist | sed 's/.*: //')
disc=$(echo "$metadata" | grep -i disc | sed 's/.*: //')
if [ "$artist" = "" ]; then
artist=$(echo "$metadata" | grep -i author | sed 's/.*: //')
fi
#### The actual conversion to AAC M4A
avconv -i "$f" -vn -f wav - | neroAacEnc -if - -"$mode" "$quality" -ignorelength "$adv" -of "${f%.*}.m4a"
#### Writing the metadata to the new M4A
neroAacTag "${f%.*}.m4a" -meta:title="$title" -meta:artist="$artist" -meta:track="$track" -meta:totaltracks="$tracktotal" -meta:genre="$genre" -meta:year="$date" -meta:album="$album" -meta:disc="$disc" -meta:composer="$album_artist"
done
exit 0
This can be used to convert any format your avconv can read to M4A with neroAacEnc (though of course, you should never transcode from one lossy format to another). Put it in your ~/bin as convert-to-m4a, and basic usage is
Code:
convert-to-m4a input.file
To get a usage message, use
Bookmarks