#!/bin/bash #This program is free software; you can redistribute it and/or modify #it under the terms of the GNU General Public License version 2 as published by #the Free Software Foundation. #This program is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #GNU General Public License for more details: #http://www.gnu.org/copyleft/gpl.html #Any questions at all, email me at: dave@davidstark.name if ! [ -e "$1" ] then echo "$1 does not exist." echo "Exiting." exit 1 fi INFILE="$1" if file -L "$INFILE" | grep RIFF | grep PCM | grep "16 bit" | grep stereo | grep 44100 &> /dev/null then RAWFILE="$INFILE" else if [ -e "$INFILE".wav ] then echo "Decode output file: $INFILE.wav already exists." echo "Exiting." exit 1 fi if ! mplayer -vo null -vc null -af lavcresample=44100,channels=2,format=s16le -ao pcm:file="$INFILE".wav "$INFILE" then echo "Couldn't decode $INFILE" echo "Exiting." exit 1 fi RAWFILE="$INFILE".wav fi if ! flac -8 "$RAWFILE" then echo "Couldn't encode $OUTFILE." echo "Exiting." if [ "$RAWFILE" != "$INFILE" ] then rm -f "$RAWFILE" fi exit 1 fi if [ "$RAWFILE" != "$INFILE" ] then rm -f "$RAWFILE" fi