1
0
Fork 0
scripts/downmix.sh

26 lines
1.0 KiB
Bash
Raw Normal View History

2022-11-21 23:03:33 +00:00
#!/bin/bash
2022-12-27 11:33:14 +00:00
# ====================================================================
# Simple script to downmix a 5.0/5.1/5.1 (side) flac file to stereo,
2022-11-21 23:02:15 +00:00
# and optionally resample to cd quality
2022-12-27 11:33:14 +00:00
#
# Dependencies: ffmpeg (built with libsoxr and flac)
# ====================================================================
2022-11-21 23:02:15 +00:00
2022-12-27 11:33:14 +00:00
read -p 'Gain db [-6]: ' GAIN
2022-11-21 22:19:36 +00:00
if [[ -z "$GAIN" ]]; then
2022-12-27 11:33:14 +00:00
GAIN=-6
2022-11-21 22:19:36 +00:00
fi
2022-11-21 23:02:15 +00:00
read -p 'Resample to cd quality? [No]: ' RES
2022-11-21 22:19:36 +00:00
mkdir -p down
for file in *.flac; do
2022-11-21 23:02:15 +00:00
if [[ -z "$RES" ]]; then
2022-12-27 11:33:14 +00:00
ffmpeg -i "$file" -af "volume=volume=${GAIN}dB:precision=double,pan=stereo| FL = FL + 0.707*FC + 0.707*BL + 0.707*SL + 0.5*LFE | FR = FR + 0.707*FC + 0.707*BR + 0.707*SR + 0.5*LFE" "down/$file"
2022-11-21 23:02:15 +00:00
else
2022-12-27 11:33:14 +00:00
ffmpeg -i "$file" -af "volume=volume=${GAIN}dB:precision=double,pan=stereo| FL = FL + 0.707*FC + 0.707*BL + 0.707*SL + 0.5*LFE | FR = FR + 0.707*FC + 0.707*BR + 0.707*SR + 0.5*LFE,aresample=resampler=soxr:precision=33:cutoff=0.96:dither_method=triangular:out_sample_rate=44100:out_sample_fmt=s16" "down/${file/%flac/wav}"
2022-11-21 23:02:15 +00:00
fi
2022-11-21 22:19:36 +00:00
done