ACPI administration advocacy advocacy advocacy opinion alsa amarok apache apple apt aptitude audio audo authentication automount avi awk bash BIOS boot business cache calendar calibre censorship commandline computerscience console cron cut database date debian degree design desktop development disk dpkg dvd economics education emacs email europe exim faad ffmpeg files firefox firewall flash foss freedom ftp fun fuse git gnumeric grep growisofs grub gtkpod hardware hardware html idiocy images installation ip iphone ipod iptables iso itunes ivman kde kernel keyboard knoppix lame laptop latex linux locale lockin longlines m4a microsoft mimetypes minitab mount mp3 mp4 mplayer multimedia music mysql network nfs nfs4 nmap openbox openoffice opinion opinion partition pdf perl php politics postgresql printing privacy programming rant remote rhythmbox rss rsync rxvt scp script scripting scsi security sed server shell siteadmin sitenews sitesoftware skype skype slackware sound sox spam spreadsheet ssh statistics subversion sudo svk swap t23 t43 terminal text thinkpad thunderbird time timezone ubuntu udev upgrade usb usbmount users uuid versioncontrol vfat video vnc windows wine wordpress wordprocessing X40 xwindows xwindows youtube
Some media players can't play protected m4a's. This script converts the m4a passed on the command line to an mp3 that can then be copied to your selected media player:
#!/usr/bin/bash
#
# copy and convert
#
# Transcode m4a file to mp3
#
# This script is heavily based on the original here:
# http://www.minigeek.org/2007/07/linux-m4a-to-mp3-conversion-script
#
# Naturally, changes are licensed under the GPL
#
orig=$1
temp_wav=`tempfile --directory ~/tmp --suffix=".wav"`
mp3=`echo "$orig"|sed -e 's/\.m4a/\.mp3/'`
temp_trackinfo=`tempfile --directory ~/tmp --suffix=".txt"`
# deal with track info
faad -i ${orig} 2>$temp_trackinfo
sed -i '23s/unknown: /title: /' $temp_trackinfo
sed -i '24s/unknown: /artist: /' $temp_trackinfo
year=`grep 'date: ' $temp_trackinfo|sed -e 's/date: //'`
sed -i 's/unknown: iTunes/iTunes: iTunes/' $temp_trackinfo
genrecount=`grep -c 'genre: ' $temp_trackinfo`
unknowncount=`grep -c 'unknown: ' $temp_trackinfo`
if [ "$genrecount" -eq 1 ] && [ "$unknowncount" -eq 2 ]; then
sed -i '25s/unknown: /composer: /' $temp_trackinfo
sed -i '26s/unknown: /album: /' $temp_trackinfo
genre=`grep 'genre: ' $temp_trackinfo|sed -e 's/genre: //'`
fi
if [ "$genrecount" -eq 1 ] && [ "$unknowncount" -eq 1 ]; then
sed -i '25s/unknown: /album: /' $temp_trackinfo
genre=`grep 'genre: ' $temp_trackinfo|sed -e 's/genre: //'`
fi
if [ "$genrecount" -eq 0 ] && [ "$unknowncount" -eq 3 ]; then
sed -i '25s/unknown: /composer: /' $temp_trackinfo
sed -i '26s/unknown: /album: /' $temp_trackinfo
sed -i '27s/unknown: /genre: /' $temp_trackinfo
genre='other'
fi
if [ "$genrecount" -eq 0 ] && [ "$unknowncount" -eq 2 ]; then
sed -i '25s/unknown: /album: /' $temp_trackinfo
sed -i '26s/unknown: /genre: /' $temp_trackinfo
genre='other'
fi
title=`grep 'title: ' $temp_trackinfo|sed -e 's/title: //'`
artist=`grep 'artist: ' $temp_trackinfo|sed -e 's/artist: //'`
album=`grep 'album: ' $temp_trackinfo|sed -e 's/album: //'`
track=`grep 'track: ' $temp_trackinfo|sed -e 's/track: //'`
## convert to wav
faad -o $temp_wav $orig
## convert to mp3
lame --alt-preset 192 --id3v2-only --tt "$title" --ta "$artist" --tl "$album" --tg "$genre" --tn "$track" --ty "$year" "$temp_wav" "$mp3"
## clean-up
rm $temp_wav
rm $temp_trackinfo
exit 0