commit | author | age
|
4ce3ae
|
1 |
#!/bin/bash |
JG |
2 |
|
828250
|
3 |
# Script to transcode music in buld using ffmpeg |
JG |
4 |
|
|
5 |
bitrate=192000 |
|
6 |
|
4ce3ae
|
7 |
shopt -s globstar |
JG |
8 |
|
|
9 |
rm -r trans_music |
|
10 |
mkdir trans_music |
|
11 |
|
|
12 |
cp -r --attributes-only Music/* trans_music/ |
|
13 |
find trans_music -type f -delete |
|
14 |
for d in **/*.{mp3,flac,mp4,m4a,ogg}; do |
|
15 |
if [ "ffprobe -show_format 2>/dev/null $d | grep bit_rate | cut -d'=' -f2" > 192000 ]; then |
|
16 |
echo in $d |
828250
|
17 |
echo out "trans_music/$(echo ${d%.*} | cut -f1 -d'/' --complement).mp3" |
222167
|
18 |
ffmpeg -i "$d" -b:a $bitrate "trans_music/$(echo ${d%.*} | cut -f1 -d'/' --complement).mp3" |
4ce3ae
|
19 |
else |
222167
|
20 |
cp "$d" "trans_music/$(echo $d | cut -f1 -d'/' --complement)" |
4ce3ae
|
21 |
fi |
JG |
22 |
done |