diff --git a/encode.bash b/encode.bash index e79c8c8..22d76a0 100755 --- a/encode.bash +++ b/encode.bash @@ -32,13 +32,13 @@ function clean { if [ -f "$1" ] then echo "Cleaning existing file, $1." - rm $1 + rm "$1" fi } if [ -z "$1" ] then - echo "Provide a cast type!" + echo "Provide a cast config!" echo "$0 [date]" exit 1 fi @@ -49,22 +49,22 @@ then echo "$0 [date]" exit 2 fi -slug=$2 +slug="$2" if [ -z "$3" ] then date=$(date +%Y-%m-%d) year=$(date +%Y) post_date=$(date +%Y/%m/%d) else - date=$(date +%Y-%m-%d -d $3) - year=$(date +%Y -d $3) - post_date=$(date +%Y/%m/%d -d $3) + date=$(date +%Y-%m-%d -d "$3") + year=$(date +%Y -d "$3") + post_date=$(date +%Y/%m/%d -d "$3") fi # load info from cast specific config file -. $config +. "$config" -if [ -z "${file_prefix}" ] +if [ -z "$file_prefix" ] then echo "${config} must set file_prefix." exit 1 @@ -88,7 +88,7 @@ clean "${base_file}.mp3" echo "" # encode lossy, MP3, adding ID3v2 tags for everything # *except* cover art -lame -b ${mp3_bitrate} \ +lame -b "${mp3_bitrate}" \ --cbr \ --tt "${title}" \ --ta "${artist}" \ @@ -98,91 +98,28 @@ lame -b ${mp3_bitrate} \ --tg "${genre}" \ --id3v2-only \ --noreplaygain \ -${base_file}.wav \ -${base_file}.mp3 +"${base_file}".flac \ +"${base_file}".mp3 # lame package from Lucid lacks the --ti switch for image # found eyed3 via a web search -eyeD3 --add-image ${cover}:FRONT_COVER \ +eyeD3 --add-image "${cover}":FRONT_COVER \ --url-frame="WCOP:${copyright}" \ -${base_file}.mp3 +"${base_file}".mp3 echo "" -echo "Encoding ${base_file}.flac." -clean "${base_file}.flac" +echo "Tagging ${base_file}.flac." echo "" # lossless encoding -flac \ ---picture="|image/jpeg|||${cover}" \ ---tag=title="${title}" \ ---tag=artist="${artist}" \ ---tag=album="${album}" \ ---tag=year="${year}" \ ---tag=genre="${genre}" \ ---tag=composer="${artist}" \ ---tag=comment="${comment}" \ ---tag=url="${url}" \ ---tag=copyright="${copyright}" \ -${base_file}.wav - -echo "" -echo "Encoding ${base_file}.m4a at ${aac_quality}." -clean "${base_file}.m4a" -echo "" -# AAC encoding, lossy -# docs recommend against setting bandwidth and bitrate setting -# doesn't seem to result in the desired quality as tweaking -# the quality setting (max 500)--200 was arrived at by iteratively -# encoding the same raw audio and subjective listening to the results -ffmpeg -i ${base_file}.wav \ --b:a ${aac_quality}k \ --metadata title="${title}" \ --metadata artist="${artist}" \ --metadata album="${album}" \ --metadata year="${year}" \ --metadata genre="${genre}" \ --metadata writer="${artist}" \ --metadata comment="${comment}" \ --strict experimental \ -${base_file}.m4a - -#-metadata cover-art="${cover}" \ -#-acodec fdk_aac \ - -#faac -q ${aac_quality} \ -#-o ${base_file}.m4a \ -#--title "${title}" \ -#--artist "${artist}" \ -#--album "${album}" \ -#--year "${year}" \ -#--genre "${genre}" \ -#--writer "${artist}" \ -#--comment "${comment}" \ -#--cover-art "${cover}" \ -#${base_file}.wav - -if [ -f "${aac_notes_path}/${date}.notes" ] -then - # put together the just-so input file for mp4chaps - echo "00:00:00.000 Start" > \ - ${base_file}.chapters.txt - grep "{{offset|" ${aac_notes_path}/${date}.notes | \ - sed -e "s/.*offset|\(.*\)}}.*|\(.*\)}}.*/\1 \2/" >> \ - ${base_file}.chapters.txt - - # write the chapter marks to the AAC/MP4 file - mp4chaps -o -z -i ${base_file}.m4a -fi - -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 -# already set into the flac file except the cover art; -# using metaflac, can encode the binary block in flac -# per the latest recommendations from Xiph for cover art -oggenc \ --q ${ogg_quality} \ ---comment=METADATA_BLOCK_PICTURE="$(metaflac --export-picture-to=- ${base_file}.flac| base64 -w 0)" \ -${base_file}.flac +metaflac \ +--import-picture-from="|image/png|||${cover}" \ +--set-tag=title="${title}" \ +--set-tag=artist="${artist}" \ +--set-tag=album="${album}" \ +--set-tag=year="${year}" \ +--set-tag=genre="${genre}" \ +--set-tag=composer="${artist}" \ +--set-tag=comment="${comment}" \ +--set-tag=url="${url}" \ +--set-tag=copyright="${copyright}" \ +"${base_file}".flac