]> code.delx.au - transcoding/blob - fix-pal-speedup
hencode: default to copying audio streams
[transcoding] / fix-pal-speedup
1 #!/bin/bash -e
2
3 # Many DVDs released in Australia are sped up from 24fps to 25fps.
4 # This script reverses the procedure, correcting the audio pitch.
5 # The video framerate is adjusted without re-encoding. The audio is slowed and
6 # normalised then re-encoded as mp3.
7
8 if [ -z "$1" -o -z "$2" ]; then
9 echo "Usage: $0 destdir infile [infile ...]"
10 exit 1
11 fi
12
13 FORCEFPS="24"
14 SLOWDOWN="0.96"
15
16 destdir="$1"
17 shift
18
19 for infile in "$@"; do
20 outfile="$destdir/$(basename "$infile")"
21 tmpdir="$(tempfile -p 'pal-')"
22 rm "$tmpdir"
23
24 if [ -f "$outfile" ]; then
25 echo "Not overwriting $outfile"
26 continue
27 fi
28
29 set -x
30 mkdir "$tmpdir"
31 mplayer -novideo -ao pcm:file="${tmpdir}/audio.wav" -vo null "$infile"
32 sox "${tmpdir}/audio.wav" "${tmpdir}/audio-fixed.wav" speed "${SLOWDOWN}" gain -n
33 lame --preset standard "${tmpdir}/audio-fixed.wav" "${tmpdir}/audio.mp3"
34 mkvmerge -o "${outfile}" --default-duration "1:${FORCEFPS}fps" --no-audio "$infile" "${tmpdir}/audio.mp3"
35
36 rm -rf "$tmpdir"
37 done
38