-
Notifications
You must be signed in to change notification settings - Fork 0
/
movie-night.sh
89 lines (80 loc) · 1.76 KB
/
movie-night.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
function warn {
printf '\e[36m%s\e[m\n' "$*"
}
function log {
unset PS4
sx=$((set -x
: "$@") 2>&1)
warn "${sx:2}"
"$@"
}
function hx {
printf 0x%04x%04x $*
}
function bf {
regtool set /user/console/ScreenBufferSize $(hx 2000 $1)
regtool set /user/console/WindowSize $(hx 25 $1)
cygstart bash $2
kill -7 $$ $PPID
}
if (( $# != 1 ))
then
echo ${0##*/} FILE
exit
fi
sc=$1
# lets split out the good downmix, because that might be a while
echo Checking downmix
wget -q https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/libswresample\
/options.c
(( $? )) && exit
awk '/center_mix_level/ && /C_30DB/ {exit 1}' swresample.c
bad=$?
rm swresample.c
if (( ! bad ))
then
warn Good downmix available, fix script
exit
fi
# get streams
ffprobe -v 0 -of csv -show_streams "$sc" > streams.csv
c2=$(awk '/stereo/,$0=$2' FS=, streams.csv)
c6=$(awk '/5\.1/,$0=$2' FS=, streams.csv)
rm streams.csv
ag=(
"-hide_banner"
"-i '$sc'"
"-map v"
"-map :$c6"
"-c:v copy"
"-b:a 256k"
"-ac 2"
"-clev 3dB"
"-slev -6dB"
"-metadata 'comment=clev 3dB slev -6dB'"
)
case ${#c2}${#c6} in
01)
ao+=("echo One 5.1 stream, use my downmix")
ao+=("log ffmpeg ${ag[*]} mn-'$sc'")
;;
10)
ao+=("echo One stereo stream, reject file")
;;
11)
ao+=("echo Dual audio, use my downmix on 5.1 stream")
ao+=("log ffmpeg ${ag[*]} mn-'$sc'")
;;
esac
ao+=("warn Press any key to continue . . .")
ao+=("read")
ao+=("rm rx.sh")
ao+=("bf 80")
printf '%s\n' "${ao[@]}" > rx.sh
export -f bf hx log warn
bf 88 rx.sh
# if i am going to be transcoding anyway, i might as well use ffmpeg for the
# volume too
# ffmpeg -i a.mkv -c:v copy -af volume=3dB -b:a 384k out.mp4
# ffmpeg -i infile -vn -af volumedetect -f null -
# ffmpeg -i infile -vn -filter_complex ebur128=peak=true -f null -