1
0
Fork 0

Update and fix scripts

This commit is contained in:
MGislv 2022-12-27 12:33:14 +01:00
parent 1668c64b23
commit d54497475f
3 changed files with 44 additions and 13 deletions

View File

@ -1,10 +1,15 @@
#!/bin/bash
# Simple script to downmix a 5.1/5.1 (side) flac file to stereo,
# and optionally resample to cd quality
read -p 'Gain db [+3db]: ' GAIN
# ====================================================================
# Simple script to downmix a 5.0/5.1/5.1 (side) flac file to stereo,
# and optionally resample to cd quality
#
# Dependencies: ffmpeg (built with libsoxr and flac)
# ====================================================================
read -p 'Gain db [-6]: ' GAIN
if [[ -z "$GAIN" ]]; then
GAIN=3
GAIN=-6
fi
read -p 'Resample to cd quality? [No]: ' RES
@ -13,8 +18,8 @@ mkdir -p down
for file in *.flac; do
if [[ -z "$RES" ]]; then
ffmpeg -i "$file" -af "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,volume=${GAIN}dB" "down/$file"
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"
else
ffmpeg -i "$file" -af "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,volume=${GAIN}dB,aresample=resampler=soxr:precision=28" -sample_fmt s16 -ar 44100 -map_metadata -1 "down/${file/%flac/wav}"
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}"
fi
done

View File

@ -1,17 +1,17 @@
#!/bin/bash
read -p 'Input bitrate: ' BITRATE
read -p 'Bitrate [192]: ' BITRATE
if [[ -z "$BITRATE" ]]; then
BITRATE=160
BITRATE=192
fi
read -p 'Gain db: ' GAIN
read -p 'Gain db [-1]: ' GAIN
if [[ -z "$GAIN" ]]; then
GAIN=-2
GAIN=-1
fi
mkdir -p opus
for file in ./*.flac; do
sox -V "$file" -t flac - gain $GAIN rate -v 48000 | opusenc --bitrate $BITRATE \
- "./opus/${file/%flac/ogg}"
for file in *.flac; do
sox -V3 -D "$file" -t flac -b 24 - gain "$GAIN" rate -v 48000 |
opusenc --bitrate "$BITRATE" - "./opus/${file/%flac/ogg}"
done

26
resampletocdq.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
# ===============================================================
# Script for resampling flac/wav files to cd resolution
#
# Dependencies: SoX
# ===============================================================
read -p 'Gain db [0]: ' GAIN
if [[ -z "$GAIN" ]]; then
GAIN=0
fi
read -p 'Format of source is wav? [flac]: ' FORMAT
mkdir -p resampled
if [[ -z "$FORMAT" ]]; then
for file in *.flac; do
sox -V3 "$file" -b 16 "resampled/${file/%flac/wav}" gain "$GAIN" rate -v 44100 dither -s
done
else
for file in *.wav; do
sox -V3 "$file" -b 16 "resampled/$file" gain "$GAIN" rate -v 44100 dither -s
done
fi