]>
code.delx.au - transcoding/blob - fix-pal-speedup
5b77d451163c122b638e618f181167fd0f675064
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
6 # slowed, and encoded as AAC, preserving surround sound.
8 if [ -z "$1" -o -z "$2" ]; then
9 echo "Usage: $0 infile outfile"
15 SLOWFILTER
="-filter asetrate=46080,aresample=osr=48000:resampler=soxr"
17 function mux_replace_audio
{
22 local audiodelay
="$(get_minimum_timestamp "$infile" "audio
")"
23 local videodelay
="$(get_minimum_timestamp "$infile" "video
")"
24 local videotrackid
="$(get_track_id "$infile" "video
")"
28 --default-duration "${videotrackid}:${FORCEFPS}fps" \
29 --sync "${videotrackid}:$((videodelay / 1000000))" \
30 --no-audio "$infile" \
31 --sync "0:$((audiodelay / 1000000))" \
35 function get_track_id
{
36 mkvmerge
-i -F json
"$1" | jq
-r ".tracks[] | select(.type == \"$2\") | .id"
39 function get_minimum_timestamp
{
40 mkvmerge
-F json
-i "$1" | jq
-r ".tracks[] | select(.type == \"$2\") | .properties.minimum_timestamp"
43 function encode_audio
{
48 -c:a libfdk_aac
-vbr 3 \
52 function convert_file
{
55 local audiofile
="${tmpdir}/audiofile.m4a"
57 encode_audio
"$infile" "$audiofile"
58 mux_replace_audio
"$infile" "$audiofile" "$outfile"
64 tmpdir
="$(mktemp -d "${TMPDIR:-/var/tmp}/pal-XXXXXXXX
")"
65 convert_file
"$infile" "$outfile"