scripts

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

commit 33302dc0a3ff30be5d2d6c940a01217133e5aea0
parent ff89e6de0b74f4ca006ce2ceb460880c0fe6fb8d
Author: lostd <lostd@2f30.org>
Date:   Wed,  2 Oct 2013 12:17:56 +0300

encode or re-encode audio files, useful command line cd ripping

Diffstat:
Aencode | 39+++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+), 0 deletions(-)

diff --git a/encode b/encode @@ -0,0 +1,39 @@ +#!/bin/sh + +# create compressed audio files from audio files +# depends: lame ffmpeg + +# to rip audio from disc use one of the following: +# cdio cdrip +# cdparanoia --batch +# cdda2wav dev=/dev/cdrom --bulk + +if test -z "$1"; then + echo usage: $(basename $0) file ... && exit 1 +fi + +LAMEOPTS=$(test -n "$LAMEOPTS" && echo "$LAMEOPTS" \ + || echo '--preset extreme') +FFOPTS=$(test -n "$FFOPTS" && echo "$FFOPTS" \ + || echo '-y -v error -vol 256 -acodec pcm_s16le -ac 2') + +ENCODE() { + # encode wave + lame $LAMEOPTS $WAV $OUT +} + +for F in "$@"; do + EXT=${F##*.} + OUT=${F%.*}.mp3 + if test "$EXT" == 'wav'; then + # is wave + WAV=$F + ENCODE + else + # dump audio to wave + WAV=$(mktemp XXXXXX.wav) + ffmpeg -i $F $FFOPTS $WAV + ENCODE + rm $WAV + fi +done