-
Notifications
You must be signed in to change notification settings - Fork 1
/
srbdconv
executable file
·38 lines (28 loc) · 1.22 KB
/
srbdconv
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
#!/bin/bash
# SRBDConv - high-quality SampleRate and BitDepth CONVersion tool for FLAC files.
# Preserves tags and file names.
# Requirements:
# - sox
# - metaflac
[ "x$bitdepth" == "x" ] && bitdepth=16
[ "x$samplerate" == "x" ] && samplerate=44100
[ "x$channels" == "x" ] && channels=2
#[ "x$srcq" == "x" ] && srcq=1
[ "x$destdir" == "x" ] && destdir="${samplerate}_${bitdepth}"
mkdir -p "$destdir"
while [ "x$1" != "x" ]; do
inflac="$1"
shift
tagfile="`mktemp --tmpdir conv_XXXXX.txt`"
partialflac="${destdir}/.`basename "${inflac}"`.tmp"
outflac="${destdir}/`basename "${inflac}"`"
echo "$inflac >>> $outflac"
metaflac --export-tags-to="$tagfile" "$inflac"
sox --replay-gain off -V -S "$inflac" -r $samplerate -b $bitdepth -e signed-integer -c $channels --endian little -t raw - rate -h dither | flac --force-raw-format --endian=little --bps=$bitdepth --sample-rate=$samplerate --sign=signed --channels=$channels --padding=$[9400+$(wc -c < "$tagfile")] -7 -o "$partialflac" -
metaflac --add-seekpoint=100x "$partialflac"
metaflac --import-tags-from="$tagfile" "$partialflac"
#metaflac --remove-replay-gain "$partialflac"
#metaflac --add-replay-gain "$partialflac"
mv "$partialflac" "$outflac"
rm -f "$tagfile"
done