scripts

misc scripts and tools
git clone git://git.2f30.org/scripts
Log | Files | Refs

encode (818B)


      1 #!/bin/sh
      2 
      3 # create compressed audio files from audio files
      4 # depends: lame ffmpeg
      5 
      6 # to rip audio from disc use one of the following:
      7 # cdio cdrip
      8 # cdparanoia --batch
      9 # cdda2wav dev=/dev/cdrom --bulk
     10 
     11 if test -z "$1"; then
     12     echo usage: $(basename $0) file ... && exit 1
     13 fi
     14 
     15 LAMEOPTS=$(test -n "$LAMEOPTS" && echo "$LAMEOPTS" \
     16     || echo '--preset extreme')
     17 FFOPTS=$(test -n "$FFOPTS" && echo "$FFOPTS" \
     18     || echo '-y -v error -vol 256 -acodec pcm_s16le -ac 2')
     19 
     20 ENCODE() {
     21     # encode wave
     22     lame $LAMEOPTS $WAV $OUT
     23 }
     24 
     25 for F in "$@"; do
     26     EXT=${F##*.}
     27     OUT=${F%.*}.mp3
     28     if test "$EXT" == 'wav'; then
     29         # is wave
     30         WAV=$F
     31         ENCODE
     32     else
     33         # dump audio to wave
     34         WAV=$(mktemp XXXXXX.wav)
     35         ffmpeg -i $F $FFOPTS $WAV
     36         ENCODE
     37         rm $WAV
     38     fi
     39 done