]> code.delx.au - transcoding/blob - fix-pal-speedup
Use mplayer to extract audio instead of mkvextract
[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"
10 exit 1
11 fi
12
13 FORCEFPS="24"
14 SLOWDOWN="0.96"
15
16 destdir="$1"
17 infile="$2"
18 outfile="$destdir/$(basename "$infile")"
19 tmpdir="$(tempfile -p 'pal-')"
20 rm "$tmpdir"
21
22 if [ -f "$outfile" ]; then
23 echo "Not overwriting $outfile"
24 exit 0
25 fi
26
27 set -x
28 mkdir "$tmpdir"
29 mplayer -novideo -ao pcm:file="${tmpdir}/audio.wav" -vo null "$infile"
30 sox "${tmpdir}/audio.wav" "${tmpdir}/audio-fixed.wav" speed "${SLOWDOWN}" gain -n
31 lame --preset standard "${tmpdir}/audio-fixed.wav" "${tmpdir}/audio.mp3"
32 mkvmerge -o "${outfile}" --default-duration "1:${FORCEFPS}fps" --no-audio "$infile" "${tmpdir}/audio.mp3"
33
34 rm -rf "$tmpdir"
35