]> code.delx.au - transcoding/commitdiff
fix-pal-speedup: work with multiple files
authorJames Bunton <jamesbunton@delx.net.au>
Tue, 18 Feb 2014 09:00:58 +0000 (20:00 +1100)
committerJames Bunton <jamesbunton@delx.net.au>
Tue, 18 Feb 2014 09:00:58 +0000 (20:00 +1100)
fix-pal-speedup

index c951ed260629b349c5e1e5b109ac247028e66123..3ac096e286d9f902971d5c85363304bbe721bc48 100755 (executable)
@@ -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