From: James Bunton Date: Tue, 18 Feb 2014 09:00:58 +0000 (+1100) Subject: fix-pal-speedup: work with multiple files X-Git-Url: https://code.delx.au/transcoding/commitdiff_plain/ef14618c34c9e025a97b374db7324763f77f0817 fix-pal-speedup: work with multiple files --- diff --git a/fix-pal-speedup b/fix-pal-speedup index c951ed2..3ac096e 100755 --- a/fix-pal-speedup +++ b/fix-pal-speedup @@ -6,7 +6,7 @@ # normalised then re-encoded as mp3. if [ -z "$1" -o -z "$2" ]; then - echo "Usage: $0 destdir infile" + echo "Usage: $0 destdir infile [infile ...]" exit 1 fi @@ -14,22 +14,25 @@ FORCEFPS="24" SLOWDOWN="0.96" destdir="$1" -infile="$2" -outfile="$destdir/$(basename "$infile")" -tmpdir="$(tempfile -p 'pal-')" -rm "$tmpdir" - -if [ -f "$outfile" ]; then - echo "Not overwriting $outfile" - exit 0 -fi - -set -x -mkdir "$tmpdir" -mplayer -novideo -ao pcm:file="${tmpdir}/audio.wav" -vo null "$infile" -sox "${tmpdir}/audio.wav" "${tmpdir}/audio-fixed.wav" speed "${SLOWDOWN}" gain -n -lame --preset standard "${tmpdir}/audio-fixed.wav" "${tmpdir}/audio.mp3" -mkvmerge -o "${outfile}" --default-duration "1:${FORCEFPS}fps" --no-audio "$infile" "${tmpdir}/audio.mp3" - -rm -rf "$tmpdir" +shift + +for infile in "$@"; do + outfile="$destdir/$(basename "$infile")" + tmpdir="$(tempfile -p 'pal-')" + rm "$tmpdir" + + if [ -f "$outfile" ]; then + echo "Not overwriting $outfile" + continue + fi + + set -x + mkdir "$tmpdir" + mplayer -novideo -ao pcm:file="${tmpdir}/audio.wav" -vo null "$infile" + sox "${tmpdir}/audio.wav" "${tmpdir}/audio-fixed.wav" speed "${SLOWDOWN}" gain -n + lame --preset standard "${tmpdir}/audio-fixed.wav" "${tmpdir}/audio.mp3" + mkvmerge -o "${outfile}" --default-duration "1:${FORCEFPS}fps" --no-audio "$infile" "${tmpdir}/audio.mp3" + + rm -rf "$tmpdir" +done