summaryrefslogtreecommitdiffstats
path: root/abs/core/linhes-scripts/myth2mp3
diff options
context:
space:
mode:
authorMichael Hanson <mihanson@linhes.org>2012-05-18 22:02:13 (GMT)
committerMichael Hanson <mihanson@linhes.org>2012-05-18 22:02:13 (GMT)
commit37ae9166eca021c99091570ef240ea7d69f13008 (patch)
tree4e828bd93580d5ff4910c4af4a2dce700572fa1b /abs/core/linhes-scripts/myth2mp3
parent05afed13b6033db8d14ab0f7e18f2cba9b277a3a (diff)
downloadlinhes_pkgbuild-37ae9166eca021c99091570ef240ea7d69f13008.zip
linhes_pkgbuild-37ae9166eca021c99091570ef240ea7d69f13008.tar.gz
linhes_pkgbuild-37ae9166eca021c99091570ef240ea7d69f13008.tar.bz2
linhes-scripts: Add normalize as a dependency for myth2mp3
Diffstat (limited to 'abs/core/linhes-scripts/myth2mp3')
-rwxr-xr-xabs/core/linhes-scripts/myth2mp327
1 files changed, 20 insertions, 7 deletions
diff --git a/abs/core/linhes-scripts/myth2mp3 b/abs/core/linhes-scripts/myth2mp3
index 504322e..9b13ee1 100755
--- a/abs/core/linhes-scripts/myth2mp3
+++ b/abs/core/linhes-scripts/myth2mp3
@@ -1,6 +1,6 @@
#!/bin/sh
# convert recordings to as mp3 audio only
-# version 1.0
+# version 1.1
# usage:
# first parameter must be %DIR%/%FILE% of the recording
@@ -20,7 +20,7 @@ OUT_DIR=/myth/music
# create temp filename so multiple instances won't conflict
TMPNAME=toMP3-$$
-TMPFILE=/myth/tmp/$TMPNAME.mp3
+TMPFILE=/myth/tmp/$TMPNAME
TMPCUTFILE=/myth/tmp/$TMPNAME.mpg
FFINPUTFILE=$1
TITLE=`echo $2 | sed 's/\//_/g'`
@@ -45,9 +45,21 @@ if [ $USECUTLIST = Y ];then
fi
fi
-# run ffmpeg to do conversion
-echo "Encoding..." >> $LOGFILE
-/usr/bin/nice -n19 /usr/bin/ffmpeg -i "$FFINPUTFILE" -vn -acodec libmp3lame -ab $BITRATE -ar 44100 -ac 2 -vol 2048 "$TMPFILE"
+# run ffmpeg to do conversion to wav
+echo "Encoding to intermediate wav..." >> $LOGFILE
+/usr/bin/nice -n19 /usr/bin/ffmpeg -i "$FFINPUTFILE" -vn -acodec pcm_s16le -ar 44100 -ac 2 "$TMPFILE.wav"
+ERROR=$?
+
+# Normalize the intermediate wav
+echo "Normalizing intermediate wav..." >> $LOGFILE
+/usr/bin/normalize -q --peak "$TMPFILE.wav"
+ERROR=$?
+
+FFINPUTFILE=$TMPFILE.wav
+
+# Fianl encode of normalized wav to mp3
+echo "Encoding to normalized wav to mp3..." >> $LOGFILE
+/usr/bin/nice -n19 /usr/bin/ffmpeg -i "$FFINPUTFILE" -vn -acodec libmp3lame -ab $BITRATE -ar 44100 -ac 2 "$TMPFILE.mp3"
ERROR=$?
# make output filename unique
@@ -60,7 +72,7 @@ do
done
# move temp file to output location
-chown mythtv "$TMPFILE" && mv "$TMPFILE" "$OUTPUTFILE"
+chown mythtv "$TMPFILE.mp3" && mv "$TMPFILE.mp3" "$OUTPUTFILE"
# stop timer
aftertime="$(date +%s)"
@@ -78,6 +90,7 @@ else
fi
# clean up left over files
-unlink $TMPFILE 2> /dev/null
+unlink $TMPFILE.mp3 2> /dev/null
+unlink $TMPFILE.wav 2> /dev/null
unlink $TMPCUTFILE 2> /dev/null
unlink $TMPCUTFILE.map 2> /dev/null