Modified encode to be useful for multiple casts.

This commit is contained in:
Thomas Gideon 2010-11-05 12:20:09 -04:00
parent 4d09fd9ce3
commit 4300e276c0
2 changed files with 62 additions and 27 deletions

1
.gitignore vendored
View file

@ -11,3 +11,4 @@
*.mp3 *.mp3
*.m4a *.m4a
*.chapters.txt *.chapters.txt
*.conf

View file

@ -28,17 +28,25 @@
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
function clean {
if [ -f "$1" ]
then
echo "Cleaning existing file, $1."
rm $1
fi
}
if [ -z "$1" ] if [ -z "$1" ]
then then
echo "Provide a cast type!" echo "Provide a cast type!"
echo "$0 <cast type> <slug> [date]" echo "$0 <cast config> <slug> [date]"
exit 1 exit 1
fi fi
type=$1 config=$1
if [ -z "$2" ] if [ -z "$2" ]
then then
echo "Provide a slug!" echo "Provide a slug!"
echo "$0 <cast type> <slug> [date]" echo "$0 <cast config> <slug> [date]"
exit 2 exit 2
fi fi
slug=$2 slug=$2
@ -52,21 +60,35 @@ else
year=$(date +%Y -d $3) year=$(date +%Y -d $3)
post_date=$(date +%Y/%m/%d -d $3) post_date=$(date +%Y/%m/%d -d $3)
fi fi
echo $date
# assemble common values for tags/comments # load info from cast specific config file
title="The Command Line ${date}" . $config
artist="Thomas Gideon"
cover="${HOME}/Dropbox/Public/color_cover_art.jpg"
album="The Command Line"
genre="Podcast"
url="http://thecommandline.net/${post_date}/${slug}/"
copyright="http://creativecommons.org/licenses/by-sa/3.0/us"
comment="Weekly ${type} cast. Email to feedback@thecommandline.net. Show notes and license information for this episode at ${url}."
if [ -z "${file_prefix}" ]
then
echo "${config} must set file_prefix."
exit 1
fi
echo "Info for tagging."
echo "Title: $title"
echo "Artist: $artist"
echo "Cover: $cover"
echo "Album: $album"
echo "Genre: $genre"
echo "URL: $url"
echo "Copyright: $copyright"
echo "Comment: $comment"
base_file=${file_prefix}${date}
echo ""
echo "Encoding MP3, ${base_file}.mp3 at ${mp3_bitrate} kbps."
clean "${base_file}.mp3"
echo ""
# encode lossy, MP3, adding ID3v2 tags for everything # encode lossy, MP3, adding ID3v2 tags for everything
# *except* cover art # *except* cover art
lame -b 112 \ lame -b ${mp3_bitrate} \
--cbr \ --cbr \
--tt "${title}" \ --tt "${title}" \
--ta "${artist}" \ --ta "${artist}" \
@ -76,15 +98,19 @@ lame -b 112 \
--tg "${genre}" \ --tg "${genre}" \
--id3v2-only \ --id3v2-only \
--noreplaygain \ --noreplaygain \
cmdln.net_${date}.wav \ ${base_file}.wav \
cmdln.net_${date}.mp3 ${base_file}.mp3
# lame package from Lucid lacks the --ti switch for image # lame package from Lucid lacks the --ti switch for image
# found eyed3 via a web search # found eyed3 via a web search
eyeD3 --add-image ${cover}:FRONT_COVER \ eyeD3 --add-image ${cover}:FRONT_COVER \
--set-text-frame="TCOP:${copyright}" \ --set-text-frame="TCOP:${copyright}" \
cmdln.net_${date}.mp3 ${base_file}.mp3
echo ""
echo "Encoding ${base_file}.flac."
clean "${base_file}.flac"
echo ""
# lossless encoding # lossless encoding
flac \ flac \
--picture="|image/jpeg|||${cover}" \ --picture="|image/jpeg|||${cover}" \
@ -97,14 +123,18 @@ flac \
--tag=comment="${comment}" \ --tag=comment="${comment}" \
--tag=url="${url}" \ --tag=url="${url}" \
--tag=copyright="${copyright}" \ --tag=copyright="${copyright}" \
cmdln.net_${date}.wav ${base_file}.wav
echo ""
echo "Encoding ${base_file}.m4a at ${aac_quality}."
clean "${base_file}.m4a"
echo ""
# AAC encoding, lossy # AAC encoding, lossy
# docs recommend against setting bandwidth and bitrate setting # docs recommend against setting bandwidth and bitrate setting
# doesn't seem to result in the desired quality as tweaking # doesn't seem to result in the desired quality as tweaking
# the quality setting (max 500)--200 was arrived at by iteratively # the quality setting (max 500)--200 was arrived at by iteratively
# encoding the same raw audio and subjective listening to the results # encoding the same raw audio and subjective listening to the results
faac -q 200 \ faac -q ${aac_quality} \
-o cmdln.net_${date}.m4a \ -o cmdln.net_${date}.m4a \
--title "${title}" \ --title "${title}" \
--artist "${artist}" \ --artist "${artist}" \
@ -114,23 +144,27 @@ faac -q 200 \
--writer "${artist}" \ --writer "${artist}" \
--comment "${comment}" \ --comment "${comment}" \
--cover-art "${cover}" \ --cover-art "${cover}" \
cmdln.net_${date}.wav ${base_file}.wav
# put together the just-so input file for mp4chaps # put together the just-so input file for mp4chaps
echo "00:00:00.000 Start" > \ echo "00:00:00.000 Start" > \
cmdln.net_${date}.chapters.txt ${base_file}.chapters.txt
grep "{{offset|" ~/Documents/cmdln_notes/weekly_archive/${date}.notes | \ grep "{{offset|" ${aac_notes_path}/${date}.notes | \
sed -e "s/.*offset|\(.*\)}}.*|\(.*\)}}.*/\1 \2/" >> \ sed -e "s/.*offset|\(.*\)}}.*|\(.*\)}}.*/\1 \2/" >> \
cmdln.net_${date}.chapters.txt ${base_file}.chapters.txt
# write the chapter marks to the AAC/MP4 file # write the chapter marks to the AAC/MP4 file
mp4chaps -o -z -i cmdln.net_${date}.m4a mp4chaps -o -z -i ${base_file}.m4a
echo ""
echo "Encoding ${base_file}.ogg at quality ${ogg_quality}."
clean "${base_file}.ogg"
echo ""
# encode the Ogg Vorbis from the flac copies the tags/comments # encode the Ogg Vorbis from the flac copies the tags/comments
# already set into the flac file except the cover art; # already set into the flac file except the cover art;
# using metaflac, can encode the binary block in flac # using metaflac, can encode the binary block in flac
# per the latest recommendations from Xiph for cover art # per the latest recommendations from Xiph for cover art
oggenc \ oggenc \
-q 5 \ -q ${ogg_quality} \
--comment=METADATA_BLOCK_PICTURE="$(metaflac --export-picture-to=- cmdln.net_${date}.flac| base64 -w 0)" \ --comment=METADATA_BLOCK_PICTURE="$(metaflac --export-picture-to=- ${base_file}.flac| base64 -w 0)" \
cmdln.net_${date}.flac ${base_file}.flac