Что-то мне скучно. Поэтому я даже решил реанимировать ЖЖ +) И, между делом, накатал скрипт для разрезания и конвертирования FLAC в MP3/OGG.
- #!/bin/sh
-
- #flacsplit 0.1
- #This script splits single flac file with cue into separate flac files
- #with tags. Also ogg or mp3 encoding of flac files possible.
-
- #REQUIREMENTS:
- # oggenc
- # cuetools
- # shntool
- # lame
-
- #This program is free software; you can redistribute it and/or
- #modify it under the terms of the GNU General Public License
- #as published by the Free Software Foundation; either version 2
- #of the License, or (at your option) any later version.
-
- #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.
-
- #You should have received a copy of the GNU General Public License
- #along with this program; if not, write to the Free Software
- #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- PROGNAME="flacsplit"
- PROGVER="0.1"
- FLACDIR="flac"
- OGGDIR='ogg'
- MP3DIR='mp3'
-
- # Check input files
- case "$1" in
- *.[fF][lL][aA][cC])
- if [ ! -f "$1" ] ; then
- echo "$PROGNAME: error: flac file $1 doesn't exist"
- exit 1
- fi
- if [ ! -f "$2" ]; then
- echo "$PROGNAME: error: cue input file $2 doesn't exist"
- exit 1
- fi ;;
- *) # No parameters - show info
- echo -e "\n$PROGNAME - tool for splitting and encoding flac files with cue files. Version $PROGVER"
- echo -e "Usage: $PROGNAME flac_file cue_file [options]\nOptions can be: -m for mp3 encoding or -o for ogg encoding.\n"
- exit ;;
- esac
-
- # Sptitting
-
- if [ -d $FLACDIR ]
- then :
- else
- echo "$PROGNAME: creating output directory"
- mkdir $FLACDIR
- fi
-
- # Split flac file into separate *.flac
- shnsplit -o flac -f *.cue -t "%n-%p_-_%t" -d $FLACDIR *.flac
-
- # Use cuetag script to write tags
- cp $2 $FLACDIR
- cd $FLACDIR
- cuetag $2 *.flac
- rm $2
-
- # Encoding (if needed)
- case "$3" in
- -o)
- # encode files
- oggenc -q10 *.flac
-
- # move ogg files to $OGGDIR
- if [ -d $OGGDIR ]
- then :
- else
- mkdir $OGGDIR
- fi
- mv *.ogg $OGGDIR
- ;;
- -m)
- for flac in *.flac;
- do
- #output mp3 filename
- mpeg=`echo $flac | cut -f1 -d.`.mp3
- #mp3 tags
- TITLE="`metaflac --show-tag=TITLE "$flac" | awk -F = '{printf $2}'`"
- ALBUM="`metaflac --show-tag=ALBUM "$flac" | awk -F = '{printf $2}'`"
- ARTIST="`metaflac --show-tag=ARTIST "$flac" | awk -F = '{printf $2}'`"
- TRACKNUMBER="`metaflac --show-tag=TRACKNUMBER "$flac" | awk -F = '{printf $2}'`"
- #encode
- flac -d -c "$flac" | lame --cbr -b 320 --tt "$TITLE" --tn "$TRACKNUMBER" --tl "$ALBUM" --ta "$ARTIST" --add-id3v2 - "$mpeg"
- done
-
- # move mp3 files to $MP3DIR
- if [ -d $MP3DIR ]
- then :
- else
- mkdir $MP3DIR
- fi
- mv *.mp3 $MP3DIR
- ;;
- *)
- ;;
- esac
-
- echo -e "\n$PROGNAME: all jobs finished"