From 498f267fa4db6aa643ecdc78782f14e60e335985 Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Tue, 23 Apr 2013 22:50:01 -0400 Subject: [PATCH] change to 4-space indentation see: http://ffmpeg.org/developer.html#Code-formatting-conventions --- barcodeinterpret | 67 ++++---- blackatends | 12 +- checksumpackage | 50 +++--- fix_left2stereo | 34 ++-- fix_rewrap | 34 ++-- fix_volume | 52 +++---- ingestfile | 224 +++++++++++++------------- makebroadcast | 146 ++++++++--------- makedvd | 164 +++++++++---------- makeframes | 24 +-- makelossless | 122 +++++++-------- makemetadata | 128 +++++++-------- makepodcast | 76 ++++----- makeyoutube | 132 ++++++++-------- mmfunctions | 398 +++++++++++++++++++++++------------------------ mmhelp | 118 +++++++------- mmvariables | 6 +- paperingest | 6 +- quickcompare | 4 +- removeDSStore | 14 +- uploadomneon | 50 +++--- xdcamingest | 374 ++++++++++++++++++++++---------------------- 22 files changed, 1117 insertions(+), 1118 deletions(-) diff --git a/barcodeinterpret b/barcodeinterpret index 4ade7e8a..52d33fad 100755 --- a/barcodeinterpret +++ b/barcodeinterpret @@ -5,58 +5,57 @@ scriptdir=`dirname "$0"` . "$scriptdir/mmfunctions" || { echo "Missing '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;}; cleanup(){ - log -a "Process aborted" - exit 1 + log -a "Process aborted" + exit 1 } trap cleanup SIGHUP SIGINT SIGTERM log -b -if test $# != 1 -then -echo "You must supply one argument, a scanned interleaved 2/5 barcode value"; exit +if test $# != 1 ; then + echo "You must supply one argument, a scanned interleaved 2/5 barcode value"; exit fi barcode="$1" translatebyte() { - val=`echo $1 | echo $(cut -c $2-$3) + 32 | bc` - if [ "$val" = 131 ] ; then - echo 9 | awk '{printf("%c", $0);}' - else - echo $val | awk '{printf("%c", $0);}' - fi + val=`echo $1 | echo $(cut -c $2-$3) + 32 | bc` + if [ "$val" = 131 ] ; then + echo 9 | awk '{printf("%c", $0);}' + else + echo $val | awk '{printf("%c", $0);}' + fi } addcolons() { - echo $(echo $1 | cut -c 1-2):$(echo $1 | cut -c 3-4):$(echo $1 | cut -c 5-6):$(echo $1 | cut -c 7-8) + echo $(echo $1 | cut -c 1-2):$(echo $1 | cut -c 3-4):$(echo $1 | cut -c 5-6):$(echo $1 | cut -c 7-8) } get_ids() { - barcode=$1 - c00=`translatebyte $barcode 2 3` - c01=`translatebyte $barcode 4 5` - c02=`translatebyte $barcode 6 7` - c03=`translatebyte $barcode 8 9` - c04=`translatebyte $barcode 10 11` - c05=`translatebyte $barcode 12 13` - c06=`translatebyte $barcode 14 15` - c07=`translatebyte $barcode 16 17` - c08=`translatebyte $barcode 18 19` - c09=`translatebyte $barcode 20 21` - c10=`translatebyte $barcode 22 23` - c11=`translatebyte $barcode 24 25` - c12=`translatebyte $barcode 26 27` - c13=`translatebyte $barcode 28 29` - c14=`translatebyte $barcode 30 31` - c15=`translatebyte $barcode 32 33` - c16=`translatebyte $barcode 34 35` - c17=`translatebyte $barcode 36 37` - c18=`translatebyte $barcode 38 39` - c19=`translatebyte $barcode 40 41` - echo $c00$c01$c02$c03$c04$c05$c06$c07$c08$c09$c10$c11$c12$c13$c14$c15$c16$c17$c18$c19 + barcode=$1 + c00=`translatebyte $barcode 2 3` + c01=`translatebyte $barcode 4 5` + c02=`translatebyte $barcode 6 7` + c03=`translatebyte $barcode 8 9` + c04=`translatebyte $barcode 10 11` + c05=`translatebyte $barcode 12 13` + c06=`translatebyte $barcode 14 15` + c07=`translatebyte $barcode 16 17` + c08=`translatebyte $barcode 18 19` + c09=`translatebyte $barcode 20 21` + c10=`translatebyte $barcode 22 23` + c11=`translatebyte $barcode 24 25` + c12=`translatebyte $barcode 26 27` + c13=`translatebyte $barcode 28 29` + c14=`translatebyte $barcode 30 31` + c15=`translatebyte $barcode 32 33` + c16=`translatebyte $barcode 34 35` + c17=`translatebyte $barcode 36 37` + c18=`translatebyte $barcode 38 39` + c19=`translatebyte $barcode 40 41` + echo $c00$c01$c02$c03$c04$c05$c06$c07$c08$c09$c10$c11$c12$c13$c14$c15$c16$c17$c18$c19 } ids=`get_ids $barcode` diff --git a/blackatends b/blackatends index 11d4a23e..341b6851 100755 --- a/blackatends +++ b/blackatends @@ -5,8 +5,8 @@ scriptdir=`dirname "$0"` . "$scriptdir/mmfunctions" || { echo "Missing '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;}; cleanup(){ - log -a "Process aborted" - exit 1 + log -a "Process aborted" + exit 1 } trap cleanup SIGHUP SIGINT SIGTERM @@ -15,9 +15,9 @@ log -b [ "$#" = 0 ] && { ask_input ; once="y" ;}; while [ "$*" != "" -o "$once" = "y" ] ; do - once="n" - [ "$#" != 0 ] && sourcefile="$1" - black_at_ends "$sourcefile" - shift + once="n" + [ "$#" != 0 ] && sourcefile="$1" + black_at_ends "$sourcefile" + shift done log -e diff --git a/checksumpackage b/checksumpackage index 5931f25a..921d364d 100755 --- a/checksumpackage +++ b/checksumpackage @@ -8,8 +8,8 @@ scriptdir=`dirname "$0"` . "$scriptdir/mmfunctions" || { echo "Missing '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;}; cleanup(){ - log -a "Process aborted" - exit 1 + log -a "Process aborted" + exit 1 } trap cleanup SIGHUP SIGINT SIGTERM @@ -22,28 +22,28 @@ CHECKSUMNAME="checksum.md5" DFXMLNAME="dfxml.xml" while [ "$*" != "" ] ; do - if [ -d "$1" ] ; then - pwd=`pwd` - "$scriptdir/removeDSStore" "$1" - if [ ! -s "${1}/metadata/$CHECKSUMNAME" -o ! -s "${1}/$CHECKSUMNAME" ] ; then - report -dt "making Digital Forensics XML (${DFXMLNAME}) and $CHECKSUMNAME for ${1}" - cd "$1" - if [ -d objects ] ; then - md5deep -drl objects > "metadata/$DFXMLNAME" - xml sel -T -t -m "/dfxml/fileobject" -v "hashdigest" -o " " -v "ctime" -o " " -v "filename" -n "metadata/$DFXMLNAME" > "metadata/$CHECKSUMNAME" - else - maketemp - md5deep -drl . > $TMPFILE - mv $TMPFILE "$DFXMLNAME" - xml sel -T -t -m "/dfxml/fileobject" -v "hashdigest" -o " " -v "ctime" -o " " -v "filename" -n "$DFXMLNAME" > "$CHECKSUMNAME" - fi - cd "$pwd" - else - report -dt "${CHECKSUMNAME} already exists, skipping for ${1}" - fi - else - report -dt "ERROR: $0 requires directories as input and $1 is not a directory." - fi - shift + if [ -d "$1" ] ; then + pwd=`pwd` + "$scriptdir/removeDSStore" "$1" + if [ ! -s "${1}/metadata/$CHECKSUMNAME" -o ! -s "${1}/$CHECKSUMNAME" ] ; then + report -dt "making Digital Forensics XML (${DFXMLNAME}) and $CHECKSUMNAME for ${1}" + cd "$1" + if [ -d objects ] ; then + md5deep -drl objects > "metadata/$DFXMLNAME" + xml sel -T -t -m "/dfxml/fileobject" -v "hashdigest" -o " " -v "ctime" -o " " -v "filename" -n "metadata/$DFXMLNAME" > "metadata/$CHECKSUMNAME" + else + maketemp + md5deep -drl . > $TMPFILE + mv $TMPFILE "$DFXMLNAME" + xml sel -T -t -m "/dfxml/fileobject" -v "hashdigest" -o " " -v "ctime" -o " " -v "filename" -n "$DFXMLNAME" > "$CHECKSUMNAME" + fi + cd "$pwd" + else + report -dt "${CHECKSUMNAME} already exists, skipping for ${1}" + fi + else + report -dt "ERROR: $0 requires directories as input and $1 is not a directory." + fi + shift done log -e diff --git a/fix_left2stereo b/fix_left2stereo index daa8f42f..8f8ce9b8 100755 --- a/fix_left2stereo +++ b/fix_left2stereo @@ -5,8 +5,8 @@ scriptdir=`dirname "$0"` . "$scriptdir/mmfunctions" || { echo "Missing '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;}; cleanup(){ - log -a "Process aborted" - exit 1 + log -a "Process aborted" + exit 1 } trap cleanup SIGHUP SIGINT SIGTERM @@ -15,27 +15,27 @@ log -b suffix="_left2stereo" if test $# != 1 ; then - report -wt "You must supply one argument. Refer to a file after calling the `basename $0` script."; exit + report -wt "You must supply one argument. Refer to a file after calling the `basename $0` script."; exit fi while [ "$*" != "" ] ; do - input_movie="$1" - name=`basename "$1"` + input_movie="$1" + name=`basename "$1"` - codec_tag_string=`ffprobe -show_streams -print_format compact "$input_movie" 2>/dev/null| grep codec_type=video | grep -o "codec_tag_string=[^|]*" | cut -d= -f2` + codec_tag_string=`ffprobe -show_streams -print_format compact "$input_movie" 2>/dev/null| grep codec_type=video | grep -o "codec_tag_string=[^|]*" | cut -d= -f2` - [ "$codec_tag_string" = "mpeg" ] && { ffmpeg_opts+=" -c:v copy -c:a pcm_s24le " ; extension="mxf" ; } ; - [ "$codec_tag_string" = "mpeg" ] || { ffmpeg_opts+=" -c:v copy -c:a pcm_s24le " ; extension="mov" ; } ; + [ "$codec_tag_string" = "mpeg" ] && { ffmpeg_opts+=" -c:v copy -c:a pcm_s24le " ; extension="mxf" ; } ; + [ "$codec_tag_string" = "mpeg" ] || { ffmpeg_opts+=" -c:v copy -c:a pcm_s24le " ; extension="mov" ; } ; - if [ -f "${input_movie%.*}${suffix}.${extension}" ] ; then - report -wt "The intended output of `basename $0` already exists. Skipping for now. Please delete \"${input_movie%.*}${suffix}.${extension}\" and rerun or figure out why you are trying to do this." - else - cmd="ffmpeg -i '$input_movie' $ffmpeg_opts -filter pan=stereo:c0=c0:c1=c0 '${input_movie%.*}${suffix}.${extension}'" - echo "$cmd" - eval "$cmd" - report -dt " `basename $0` is done with ${name}." - fi - shift + if [ -f "${input_movie%.*}${suffix}.${extension}" ] ; then + report -wt "The intended output of `basename $0` already exists. Skipping for now. Please delete \"${input_movie%.*}${suffix}.${extension}\" and rerun or figure out why you are trying to do this." + else + cmd="ffmpeg -i '$input_movie' $ffmpeg_opts -filter pan=stereo:c0=c0:c1=c0 '${input_movie%.*}${suffix}.${extension}'" + echo "$cmd" + eval "$cmd" + report -dt " `basename $0` is done with ${name}." + fi + shift done log -e diff --git a/fix_rewrap b/fix_rewrap index 4d553936..82d8ee2f 100755 --- a/fix_rewrap +++ b/fix_rewrap @@ -5,35 +5,35 @@ scriptdir=`dirname "$0"` . "$scriptdir/mmfunctions" || { echo "Missing '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;}; cleanup(){ - log -a "Process aborted" - exit 1 + log -a "Process aborted" + exit 1 } trap cleanup SIGHUP SIGINT SIGTERM log -b if test $# != 1 ; then - report -wt "You must supply one argument. Refer to a file after calling the `basename $0` script."; exit + report -wt "You must supply one argument. Refer to a file after calling the `basename $0` script."; exit fi while [ "$*" != "" ] ; do - input_movie="$1" - name=`basename "$1"` + input_movie="$1" + name=`basename "$1"` - codec_tag_string=`ffprobe -show_streams -print_format compact "$input_movie" 2>/dev/null| grep codec_type=video | grep -o "codec_tag_string=[^|]*" | cut -d= -f2` + codec_tag_string=`ffprobe -show_streams -print_format compact "$input_movie" 2>/dev/null| grep codec_type=video | grep -o "codec_tag_string=[^|]*" | cut -d= -f2` - [ "$codec_tag_string" = "mpeg" ] && { ffmpeg_opts+=" -c:v copy -c:a pcm_s24le " ; extension="mxf" ; } ; - [ "$codec_tag_string" = "mpeg" ] || { ffmpeg_opts+=" -c:v copy -c:a pcm_s24le " ; extension="mov" ; } ; + [ "$codec_tag_string" = "mpeg" ] && { ffmpeg_opts+=" -c:v copy -c:a pcm_s24le " ; extension="mxf" ; } ; + [ "$codec_tag_string" = "mpeg" ] || { ffmpeg_opts+=" -c:v copy -c:a pcm_s24le " ; extension="mov" ; } ; - if [ -f "${input_movie%.*}_voladj.${extension}" ] ; then - report -wt "The intended output of `basename $0` already exists. Skipping for now. Please delete \"${input_movie%.*}_rewrap.${extension}\" and rerun or figure out why you are trying to do this." - else - report -dt "Generating '${input_movie%.*}_rewrap.${extension}' ..." - cmd="ffmbc -i '$input_movie' -vcodec copy -acodec copy '${input_movie%.*}_rewrap.${extension}'" - eval "$cmd" - report -dt " `basename $0` is done with ${name}." - fi - shift + if [ -f "${input_movie%.*}_voladj.${extension}" ] ; then + report -wt "The intended output of `basename $0` already exists. Skipping for now. Please delete \"${input_movie%.*}_rewrap.${extension}\" and rerun or figure out why you are trying to do this." + else + report -dt "Generating '${input_movie%.*}_rewrap.${extension}' ..." + cmd="ffmbc -i '$input_movie' -vcodec copy -acodec copy '${input_movie%.*}_rewrap.${extension}'" + eval "$cmd" + report -dt " `basename $0` is done with ${name}." + fi + shift done log -e diff --git a/fix_volume b/fix_volume index 8b81ed43..99529a1a 100755 --- a/fix_volume +++ b/fix_volume @@ -8,8 +8,8 @@ scriptdir=`dirname "$0"` . "$scriptdir/mmfunctions" || { echo "Missing '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;}; cleanup(){ - log -a "Process aborted" - exit 1 + log -a "Process aborted" + exit 1 } trap cleanup SIGHUP SIGINT SIGTERM @@ -18,29 +18,29 @@ log -b [ $# = 0 ] && { report -wt "You must supply one or many arguments. Usage: $(basename $0) [ file1 file2 ... ] ."; exit 2 ;}; while [ "$*" != "" ] ; do - input_movie="$1" - name=`basename "$1"` - get_codectagstring - #[ "$codec_tag_string" = "mpeg" ] && { ffmpeg_opts+=" -c:v copy -c:a pcm_s24le" ; extension="mxf" ; } ; - #[ "$codec_tag_string" = "mpeg" ] || { ffmpeg_opts+=" -c:v copy -c:a pcm_s24le" ; extension="mov" ; } ; - [ "$codec_tag_string" = "mpeg" ] && { ffmpeg_opts+=" -c:a pcm_s24le -f s24le -ar 48000 -ac 2 " ; ffmbc_opts=" -vcodec copy -f s24le -ar 48000 -ac 2 -map_audio_channel 1:0:0:0:1:0 -map_audio_channel 1:0:1:0:1:1 " ; extension="mxf" ; } ; - [ "$codec_tag_string" = "mpeg" ] || { ffmpeg_opts+=" -c:a pcm_s24le -f s24le -ar 48000 -ac 2 " ; ffmbc_opts=" -vcodec copy -f s24le -ar 48000 -ac 2 -map_audio_channel 1:0:0:0:1:0 -map_audio_channel 1:0:1:0:1:1 " ; extension="mov" ; } ; - output_movie="${input_movie%.*}${suffix}.${extension}" - if [ -f "$output_movie" ] ; then - report -wt "The intended output of `basename $0` already exists. Skipping for now. Please delete \"$output_movie\" and rerun or figure out why you are trying to do this." - else - get_volume_adjustment "$input_movie" - if [ -n "$VOLADJ" ] ; then - report -dt "Generating $output_movie ..." - #cmd="ffmpeg -i \"$input_movie\" $ffmpeg_opts -af volume=${VOLADJ}dB '$output_movie'" - cmd="ffmpeg -i \"$input_movie\" $ffmpeg_opts -af volume=${VOLADJ}dB - | ffmbc -i \"$input_movie\" $ffmbc_opts -i pipe:0 -acodec pcm_s24le \"$output_movie\"" - report -dt "Running: $cmd" - eval "$cmd" - report -dst "Done with ${name}." - else - report -dst "Integrated loudness for $name is ${integrated_loudness}dB. Reference is $reference. No adjustment is needed for ${name}, skipping." - fi - fi - shift + input_movie="$1" + name=`basename "$1"` + get_codectagstring + #[ "$codec_tag_string" = "mpeg" ] && { ffmpeg_opts+=" -c:v copy -c:a pcm_s24le" ; extension="mxf" ; } ; + #[ "$codec_tag_string" = "mpeg" ] || { ffmpeg_opts+=" -c:v copy -c:a pcm_s24le" ; extension="mov" ; } ; + [ "$codec_tag_string" = "mpeg" ] && { ffmpeg_opts+=" -c:a pcm_s24le -f s24le -ar 48000 -ac 2 " ; ffmbc_opts=" -vcodec copy -f s24le -ar 48000 -ac 2 -map_audio_channel 1:0:0:0:1:0 -map_audio_channel 1:0:1:0:1:1 " ; extension="mxf" ; } ; + [ "$codec_tag_string" = "mpeg" ] || { ffmpeg_opts+=" -c:a pcm_s24le -f s24le -ar 48000 -ac 2 " ; ffmbc_opts=" -vcodec copy -f s24le -ar 48000 -ac 2 -map_audio_channel 1:0:0:0:1:0 -map_audio_channel 1:0:1:0:1:1 " ; extension="mov" ; } ; + output_movie="${input_movie%.*}${suffix}.${extension}" + if [ -f "$output_movie" ] ; then + report -wt "The intended output of `basename $0` already exists. Skipping for now. Please delete \"$output_movie\" and rerun or figure out why you are trying to do this." + else + get_volume_adjustment "$input_movie" + if [ -n "$VOLADJ" ] ; then + report -dt "Generating $output_movie ..." + #cmd="ffmpeg -i \"$input_movie\" $ffmpeg_opts -af volume=${VOLADJ}dB '$output_movie'" + cmd="ffmpeg -i \"$input_movie\" $ffmpeg_opts -af volume=${VOLADJ}dB - | ffmbc -i \"$input_movie\" $ffmbc_opts -i pipe:0 -acodec pcm_s24le \"$output_movie\"" + report -dt "Running: $cmd" + eval "$cmd" + report -dst "Done with ${name}." + else + report -dst "Integrated loudness for $name is ${integrated_loudness}dB. Reference is $reference. No adjustment is needed for ${name}, skipping." + fi + fi + shift done log -e diff --git a/ingestfile b/ingestfile index b2833ea6..e3c0b361 100755 --- a/ingestfile +++ b/ingestfile @@ -13,48 +13,48 @@ scriptdir=`dirname "$0"` . "$scriptdir/mmfunctions" || { echo "Missing '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;}; cleanup(){ - log -a "Process aborted" - exit 1 + log -a "Process aborted" + exit 1 } trap cleanup SIGHUP SIGINT SIGTERM usage(){ - echo - echo "$(basename $0) ${version}" - echo "This script may be run interactively by running it with no arguments or may be used with the following options." - echo "Usage: $(basename $0) [ -m mediaid ] [ -f input] [ -p processing_directory ] [-a AIP_storage_directory ] [-w podcast_delivery ] [-y youtube_delivery ] [-x Regex ] [ -l audiodecision ] [ -c cleanupdecision ] [ -o operator ] [ -q priority ]" - echo " -m mediaid" - echo " -f input" - echo " -p processing directory. Transcoding will happen here." - echo " -a Archive Information Package storage directory. Final package delivery location." - echo " -w podcast delivery" - echo " -y youtube delivery" - echo " -x Regex will identify applicability of various services." - echo " -l Use only left channel of source video in transcoding." - echo " -c Remove source file after successful ingest." - echo " -q Put in queue." - exit + echo + echo "$(basename $0) ${version}" + echo "This script may be run interactively by running it with no arguments or may be used with the following options." + echo "Usage: $(basename $0) [ -m mediaid ] [ -f input] [ -p processing_directory ] [-a AIP_storage_directory ] [-w podcast_delivery ] [-y youtube_delivery ] [-x Regex ] [ -l audiodecision ] [ -c cleanupdecision ] [ -o operator ] [ -q priority ]" + echo " -m mediaid" + echo " -f input" + echo " -p processing directory. Transcoding will happen here." + echo " -a Archive Information Package storage directory. Final package delivery location." + echo " -w podcast delivery" + echo " -y youtube delivery" + echo " -x Regex will identify applicability of various services." + echo " -l Use only left channel of source video in transcoding." + echo " -c Remove source file after successful ingest." + echo " -q Put in queue." + exit } # command-line options to set mediaid and original variables while getopts ":hm:f:p:a:w:y:xlco:q" opt; do - case "$opt" in - h) usage ;; - m) mediaid="$OPTARG";; - f) input="$OPTARG";; - p) OUTDIR_INGESTFILE="$OPTARG" ;; - a) AIP_STORAGE="$OPTARG" ;; - w) PODCASTDELIVER="$OPTARG" ;; - y) YOUTUBEDELIVER="$OPTARG" ;; - x) REGEX4PODCAST ;; - l) audiodecision="left" ;; - c) cleanupdecision="Y" ;; - o) op="$OPTARG" ;; - q) priority="put in queue" ;; - \?) echo "Invalid option: -$OPTARG" ; exit 1 ;; - :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; - esac + case "$opt" in + h) usage ;; + m) mediaid="$OPTARG";; + f) input="$OPTARG";; + p) OUTDIR_INGESTFILE="$OPTARG" ;; + a) AIP_STORAGE="$OPTARG" ;; + w) PODCASTDELIVER="$OPTARG" ;; + y) YOUTUBEDELIVER="$OPTARG" ;; + x) REGEX4PODCAST ;; + l) audiodecision="left" ;; + c) cleanupdecision="Y" ;; + o) op="$OPTARG" ;; + q) priority="put in queue" ;; + \?) echo "Invalid option: -$OPTARG" ; exit 1 ;; + :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; + esac done [ ! -d "$OUTDIR_INGESTFILE" ] && echo "The processing directory must be set. Use [ -p /path/to/processing/directory ]." && exit 1 @@ -73,52 +73,52 @@ ask_input log -b if [ "$audiodecision" = "" ] ; then - report -q "Select an audio strategy? " - PS3="Selection? " - select audiodecision in "Default audio mapping [first audio track used for stereo output]" "Only use left of the first audio track [for 21st Century]" - do - break - done + report -q "Select an audio strategy? " + PS3="Selection? " + select audiodecision in "Default audio mapping [first audio track used for stereo output]" "Only use left of the first audio track [for 21st Century]" + do + break + done fi if [ "$cleanupdecision" = "" ] ; then - report -q "Select an cleanup strategy? " - PS3="Selection? " - select cleanupdecision in "Leave source file where it is." "Remove source file after successful ingest" - do - break - done - - if [ "$cleanupdecision" = "Remove source file after successful ingest" ] ; then - cleanup="Y" - fi + report -q "Select an cleanup strategy? " + PS3="Selection? " + select cleanupdecision in "Leave source file where it is." "Remove source file after successful ingest" + do + break + done + + if [ "$cleanupdecision" = "Remove source file after successful ingest" ] ; then + cleanup="Y" + fi fi if [ "$priority" = "" ] ; then - report -q "Select an multitasking strategy? " - PS3="Selection? " - select priority in "put in queue" "start now" - do - break - done + report -q "Select an multitasking strategy? " + PS3="Selection? " + select priority in "put in queue" "start now" + do + break + done fi # blackframe analysis if [ "$blackframetest" = "Y" ] ; then - black_at_ends "$input" - if [ "$head_black" -gt "30" ] ; then - report -wt "WARNING - There are at least $head_black frames of black at the beginning of ${input}" - report -qn "Enter q to quit, any other key to continue: " - read a1 - [ "$a1" == "q" ] && exit 0 - fi - if [ "$tail_black" -gt "30" ] ; then - report -wt "WARNING - There are at least $tail_black frames of black at the end of ${input}" - report -qn "Enter q to quit, any other key to continue: " - read a2 - [ "$a2" == "q" ] && exit 0 - fi + black_at_ends "$input" + if [ "$head_black" -gt "30" ] ; then + report -wt "WARNING - There are at least $head_black frames of black at the beginning of ${input}" + report -qn "Enter q to quit, any other key to continue: " + read a1 + [ "$a1" == "q" ] && exit 0 + fi + if [ "$tail_black" -gt "30" ] ; then + report -wt "WARNING - There are at least $tail_black frames of black at the end of ${input}" + report -qn "Enter q to quit, any other key to continue: " + read a2 + [ "$a2" == "q" ] && exit 0 + fi fi objectsdir="$OUTDIR_INGESTFILE/$mediaid/objects" @@ -129,19 +129,19 @@ objectsdir="$OUTDIR_INGESTFILE/$mediaid/objects" # queue handling if [ "$priority" = "put in queue" ] ; then - echo "$mediaid" >> /tmp/queue.txt - next=$(head -n 1 /tmp/queue.txt) - while [ "$mediaid" != "$next" ] ; do - newnext=$(head -n 1 /tmp/queue.txt) - echo -n "This process is waiting behind these identifiers: " - cat /tmp/queue.txt | tr '\n' ' ' - echo - while [ "$next" = "$newnext" ] ; do - sleep 10 - newnext=$(head -n 1 /tmp/queue.txt) - done - next="$newnext" - done + echo "$mediaid" >> /tmp/queue.txt + next=$(head -n 1 /tmp/queue.txt) + while [ "$mediaid" != "$next" ] ; do + newnext=$(head -n 1 /tmp/queue.txt) + echo -n "This process is waiting behind these identifiers: " + cat /tmp/queue.txt | tr '\n' ' ' + echo + while [ "$next" = "$newnext" ] ; do + sleep 10 + newnext=$(head -n 1 /tmp/queue.txt) + done + next="$newnext" + done fi mkdir -p "$objectsdir" @@ -161,34 +161,34 @@ rsync_err="$?" # transcode if [ "$audiodecision" == "Only use left of the first audio track [for 21st Century]" -o "$audiodecision" == "left" ] ; then - "$scriptdir/makebroadcast" -l "$OUTDIR_INGESTFILE/$mediaid" + "$scriptdir/makebroadcast" -l "$OUTDIR_INGESTFILE/$mediaid" else - "$scriptdir/makebroadcast" "$OUTDIR_INGESTFILE/$mediaid" + "$scriptdir/makebroadcast" "$OUTDIR_INGESTFILE/$mediaid" fi # upload to omneon if [ "$deliverytoomneon" == "Y" ] ; then - report -dt "STATUS Uploading $servicefile to the OMNEON." - "$scriptdir/uploadomneon" "$objectsdir/service/${mediaid%.*}.mov" + report -dt "STATUS Uploading $servicefile to the OMNEON." + "$scriptdir/uploadomneon" "$objectsdir/service/${mediaid%.*}.mov" fi # access copies if [ "$makeaccesscopies" == "Y" ] ; then - report -dt "STATUS Making access copies." - "$scriptdir/makedvd" "$OUTDIR_INGESTFILE/$mediaid" - "$scriptdir/makeyoutube" "$OUTDIR_INGESTFILE/$mediaid" - if [ "$deliveraccesscopies" = "Y" ] ; then - cp -av "$OUTDIR_INGESTFILE/$mediaid/objects/access/youtube_up/" "$YOUTUBEDELIVER/" - fi - if [ `echo "$mediaid" | grep "$REGEX4PODCAST"` ] ; then - report -dt "${media} qualifies for podcast creation." - sh "$scriptdir/makepodcast" "$OUTDIR_INGESTFILE/$mediaid" - if [ "$deliveraccesscopies" == "Y" ] ; then - cp -av "$OUTDIR_INGESTFILE/$mediaid/objects/access/podcast/" "$PODCASTDELIVER/" - fi - else - report -dt "${media} does NOT qualify for podcast creation, skipping." - fi + report -dt "STATUS Making access copies." + "$scriptdir/makedvd" "$OUTDIR_INGESTFILE/$mediaid" + "$scriptdir/makeyoutube" "$OUTDIR_INGESTFILE/$mediaid" + if [ "$deliveraccesscopies" = "Y" ] ; then + cp -av "$OUTDIR_INGESTFILE/$mediaid/objects/access/youtube_up/" "$YOUTUBEDELIVER/" + fi + if [ `echo "$mediaid" | grep "$REGEX4PODCAST"` ] ; then + report -dt "${media} qualifies for podcast creation." + sh "$scriptdir/makepodcast" "$OUTDIR_INGESTFILE/$mediaid" + if [ "$deliveraccesscopies" == "Y" ] ; then + cp -av "$OUTDIR_INGESTFILE/$mediaid/objects/access/podcast/" "$PODCASTDELIVER/" + fi + else + report -dt "${media} does NOT qualify for podcast creation, skipping." + fi fi end=`get_iso8601` @@ -199,25 +199,25 @@ echo "datetime_end: ${end}" >> "$logdir/capture.log" # move and cleanup if [ "$deliverytoaipstorage" == "Y" ] ; then - rsync -rtv --progress --remove-source-files "$OUTDIR_INGESTFILE/$mediaid" "$AIP_STORAGE/" - [ `du -s "$OUTDIR_INGESTFILE/$mediaid" | awk '{print $1}'` = "0" ] && rm -r "$OUTDIR_INGESTFILE/$mediaid" - report -dt "STATUS Done. Final package has been delivered to $AIP_STORAGE/${mediaid}" + rsync -rtv --progress --remove-source-files "$OUTDIR_INGESTFILE/$mediaid" "$AIP_STORAGE/" + [ `du -s "$OUTDIR_INGESTFILE/$mediaid" | awk '{print $1}'` = "0" ] && rm -r "$OUTDIR_INGESTFILE/$mediaid" + report -dt "STATUS Done. Final package has been delivered to $AIP_STORAGE/${mediaid}" fi if [ "$cleanup" == "Y" ] ; then - if [ "$rsync_err" -gt "0" ] ; then - report -wt "Cancelling requested deletion of source file, not looking safe." - else - report -dt "Removing the source file from ${input} as requested." - rm -f "$input" - fi + if [ "$rsync_err" -gt "0" ] ; then + report -wt "Cancelling requested deletion of source file, not looking safe." + else + report -dt "Removing the source file from ${input} as requested." + rm -f "$input" + fi fi # clean up queue if [ "$priority" == "put in queue" ] ; then - tail -n +2 /tmp/queue.txt > /tmp/queue2.txt - rm /tmp/queue.txt - mv /tmp/queue2.txt /tmp/queue.txt + tail -n +2 /tmp/queue.txt > /tmp/queue2.txt + rm /tmp/queue.txt + mv /tmp/queue2.txt /tmp/queue.txt fi done log -e diff --git a/makebroadcast b/makebroadcast index 0b2bd8da..c34c9e8c 100755 --- a/makebroadcast +++ b/makebroadcast @@ -8,11 +8,11 @@ scriptdir=`dirname "$0"` # command-line options to set mediaid and original OPTIND=1 while getopts lc opt ; do - case $opt in - l) audiomapping=" -map_audio_channel 0:1:0:0:1:0 -map_audio_channel 0:1:0:0:1:1 " ;; - c) cropdetect="Y" ;; - f) input="$OPTARG" ; once="y" ;; - esac + case $opt in + l) audiomapping=" -map_audio_channel 0:1:0:0:1:0 -map_audio_channel 0:1:0:0:1:1 " ;; + c) cropdetect="Y" ;; + f) input="$OPTARG" ; once="y" ;; + esac done shift $(( ${OPTIND} - 1 )) @@ -24,93 +24,93 @@ version="1.2" # v 1.2 revert to mov and ffmbc cleanup(){ - log -a "Process aborted" - exit 1 + log -a "Process aborted" + exit 1 } trap cleanup SIGHUP SIGINT SIGTERM while [ "$*" != "" -o "$once" = "y" ] ; do - once="n" - [ "$#" != 0 ] && input="$1" - [ -d "$input" ] && { outputdir="$input/objects/service" && logdir="$input/metadata/submissionDocumentation/logs" ;}; - [ -f "$input" ] && { outputdir=`dirname "$input"`"/service" && logdir="`dirname "$input"`/service/logs" ;}; - [ ! "$outputdir" ] && { outputdir="$input/objects/service" && logdir="$input/metadata/submissionDocumentation/logs" ;}; - find_input "$input" + once="n" + [ "$#" != 0 ] && input="$1" + [ -d "$input" ] && { outputdir="$input/objects/service" && logdir="$input/metadata/submissionDocumentation/logs" ;}; + [ -f "$input" ] && { outputdir=`dirname "$input"`"/service" && logdir="`dirname "$input"`/service/logs" ;}; + [ ! "$outputdir" ] && { outputdir="$input/objects/service" && logdir="$input/metadata/submissionDocumentation/logs" ;}; + find_input "$input" - filename=`basename "$sourcefile"` - mediaid=`basename "$input" | cut -d. -f1` - + filename=`basename "$sourcefile"` + mediaid=`basename "$input" | cut -d. -f1` + log -b - servicefile="$outputdir/${mediaid%.*}.mov" - [ -s "$servicefile" ] && { report -wt "WARNING $servicefile already exists, skipping transcode" ; shift ; continue ;}; + servicefile="$outputdir/${mediaid%.*}.mov" + [ -s "$servicefile" ] && { report -wt "WARNING $servicefile already exists, skipping transcode" ; shift ; continue ;}; - report -dt "STATUS Transcoding for Omneon compliance." - ffmpeg_opts=" -r ntsc" - if [ -n "$audiomapping" ] ; then - ffmpeg_opts+=" $audiomapping" - else - has_first_two_tracks_mono "$sourcefile" - if [ "$MULTIMONO" = "Y" ] ; then - audiomapping=" -map_audio_channel 0.1:0:0.1:0 -map_audio_channel 0.2:0:0.1:1 " - ffmpeg_opts+=" $audiomapping" - fi - fi - # choose video encoding strategy, if source is xdcam 50 mb/sec ntsc then copy the video, else transcode - get_codectagstring "$sourcefile" - if [ "$codec_tag_string" = "xd5b" ] ; then - ffmpeg_opts+=" -c:v copy" - else + report -dt "STATUS Transcoding for Omneon compliance." + ffmpeg_opts=" -r ntsc" + if [ -n "$audiomapping" ] ; then + ffmpeg_opts+=" $audiomapping" + else + has_first_two_tracks_mono "$sourcefile" + if [ "$MULTIMONO" = "Y" ] ; then + audiomapping=" -map_audio_channel 0.1:0:0.1:0 -map_audio_channel 0.2:0:0.1:1 " + ffmpeg_opts+=" $audiomapping" + fi + fi + # choose video encoding strategy, if source is xdcam 50 mb/sec ntsc then copy the video, else transcode + get_codectagstring "$sourcefile" + if [ "$codec_tag_string" = "xd5b" ] ; then + ffmpeg_opts+=" -c:v copy" + else <<<<<<< HEAD - if [ "$cropdetect" = "Y" ] ; then - get_cropdetection "$sourcefile" - echo YEAHYAEAH - if [ -n "$CROPADJ" ] ;then - ffmpeg_opts+=" -vf '${CROPADJ},pad=ih*16/9:ih:(ow-iw)/2:(oh-ih)/2,scale=1920:1080:interl=1'" - else - ffmpeg_opts+=" -vf 'pad=ih*16/9:ih:(ow-iw)/2:(oh-ih)/2,scale=1920:1080:interl=1'" - fi - else - ffmpeg_opts+=" -vf 'pad=ih*16/9:ih:(ow-iw)/2:(oh-ih)/2,scale=1920:1080:interl=1'" - fi - ffmpeg_opts+=" -target xdcamhd422 -vtag xd5b -tff -aspect 16:9 -threads 4" + if [ "$cropdetect" = "Y" ] ; then + get_cropdetection "$sourcefile" + echo YEAHYAEAH + if [ -n "$CROPADJ" ] ;then + ffmpeg_opts+=" -vf '${CROPADJ},pad=ih*16/9:ih:(ow-iw)/2:(oh-ih)/2,scale=1920:1080:interl=1'" + else + ffmpeg_opts+=" -vf 'pad=ih*16/9:ih:(ow-iw)/2:(oh-ih)/2,scale=1920:1080:interl=1'" + fi + else + ffmpeg_opts+=" -vf 'pad=ih*16/9:ih:(ow-iw)/2:(oh-ih)/2,scale=1920:1080:interl=1'" + fi + ffmpeg_opts+=" -target xdcamhd422 -vtag xd5b -tff -aspect 16:9 -threads 4" ======= - ffmpeg_opts+=" -vf 'pad=ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2,scale=1920:1080:interl=1'" - ffmpeg_opts+=" -target xdcamhd422 -vtag xd5b -tff -threads 8" + ffmpeg_opts+=" -vf 'pad=ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2,scale=1920:1080:interl=1'" + ffmpeg_opts+=" -target xdcamhd422 -vtag xd5b -tff -threads 8" >>>>>>> makebroadcast: consider sar while scaling - fi + fi - # add audio options - ffmpeg_opts+=" -acodec pcm_s24le -ar 48k -ac 2" + # add audio options + ffmpeg_opts+=" -acodec pcm_s24le -ar 48k -ac 2" - # set input options for ffmpeg + # set input options for ffmpeg <<<<<<< HEAD - inputoptions=" -y -threads 4" + inputoptions=" -y -threads 4" ======= - inputoptions=" -y" - inputoptions+=" -threads 8" - inputoptions+=" -loglevel verbose" + inputoptions=" -y" + inputoptions+=" -threads 8" + inputoptions+=" -loglevel verbose" >>>>>>> makebroadcast: enable multi-threading and increase verbosity - mkdir -p "$outputdir" - ffmpeg_command="ffmbc $inputoptions -i \"$sourcefile\" $ffmpeg_opts \"$servicefile\"" - # log ffmpeg process - if [ "$logdir" != "" ] ; then - mkdir -p "$logdir" - reportfile="ffmbc_$(date '+%Y%m%d-%H%M%S')_$(basename $0)_${version}.txt" - echo "ffmbc started on $(date '+%F at %T')" > "${logdir}/${reportfile}" - echo "Report written to \"${reportfile}\"" >> "${logdir}/${reportfile}" - echo "Command line:" >> "${logdir}/${reportfile}" - fi - report -dt "Running: ${ffmpeg_command}" - echo "$ffmpeg_command" >> "${logdir}/${reportfile}" - eval "$ffmpeg_command" - ffmpeg_err="$?" + mkdir -p "$outputdir" + ffmpeg_command="ffmbc $inputoptions -i \"$sourcefile\" $ffmpeg_opts \"$servicefile\"" + # log ffmpeg process + if [ "$logdir" != "" ] ; then + mkdir -p "$logdir" + reportfile="ffmbc_$(date '+%Y%m%d-%H%M%S')_$(basename $0)_${version}.txt" + echo "ffmbc started on $(date '+%F at %T')" > "${logdir}/${reportfile}" + echo "Report written to \"${reportfile}\"" >> "${logdir}/${reportfile}" + echo "Command line:" >> "${logdir}/${reportfile}" + fi + report -dt "Running: ${ffmpeg_command}" + echo "$ffmpeg_command" >> "${logdir}/${reportfile}" + eval "$ffmpeg_command" + ffmpeg_err="$?" <<<<<<< HEAD - [ "$ffmpeg_err" -gt "0" ] && { report -wt "ffmpeg failed with error ${ffmpeg_err}" && exit 1;}; + [ "$ffmpeg_err" -gt "0" ] && { report -wt "ffmpeg failed with error ${ffmpeg_err}" && exit 1;}; ======= - [ "$ffmpeg_err" -gt "0" ] && { report "${RED}ffmbc failed with error ${ffmpeg_err}${NC}" && exit 1;}; + [ "$ffmpeg_err" -gt "0" ] && { report "${RED}ffmbc failed with error ${ffmpeg_err}${NC}" && exit 1;}; >>>>>>> makebroadcast: remove logging for now - shift + shift done log -e diff --git a/makedvd b/makedvd index ab723127..2c44faf3 100755 --- a/makedvd +++ b/makedvd @@ -7,8 +7,8 @@ scriptdir=`dirname "$0"` . "$scriptdir/mmfunctions" || { echo "Missing '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;}; cleanup(){ - log -a "Process aborted" - exit 1 + log -a "Process aborted" + exit 1 } trap cleanup SIGHUP SIGINT SIGTERM @@ -16,28 +16,28 @@ trap cleanup SIGHUP SIGINT SIGTERM usage(){ echo - echo "$(basename $0) ${version}" - echo "This script may be run interactively by running it with no arguments or may be used with the following options." - echo "Usage: $(basename $0) [ -m mediaid ] [ -f sourcefile ] [ -v dvd_label_prefix ]" - echo " -m mediaid" - echo " -f sourcefile" - echo " -v dvdlabelprefix" - echo " -h display this help" - echo - exit + echo "$(basename $0) ${version}" + echo "This script may be run interactively by running it with no arguments or may be used with the following options." + echo "Usage: $(basename $0) [ -m mediaid ] [ -f sourcefile ] [ -v dvd_label_prefix ]" + echo " -m mediaid" + echo " -f sourcefile" + echo " -v dvdlabelprefix" + echo " -h display this help" + echo + exit } # command-line options to set mediaid and original variables OPTIND=1 while getopts ":hm:f:v:" opt; do - case "$opt" in - h) usage ;; - m) mediaid="$OPTARG";; - f) input="$OPTARG" ; once="y" ;; - v) DVDLABELPREFIX="$OPTARG";; - *) echo "bad option -$OPTARG" ; usage ;; - :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; - esac + case "$opt" in + h) usage ;; + m) mediaid="$OPTARG";; + f) input="$OPTARG" ; once="y" ;; + v) DVDLABELPREFIX="$OPTARG";; + *) echo "bad option -$OPTARG" ; usage ;; + :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; + esac done shift $(( ${OPTIND} - 1 )) @@ -46,74 +46,74 @@ check_dependencies ffmpeg dvdauthor mkisofs [ "$#" = 0 -a ! "$input" ] && { ask_input ; once="y" ;}; while [ "$*" != "" -o "$once" = "y" ] ; do - once="n" + once="n" - [ "$#" != 0 ] && input="$1" - [ -d "$input" ] && { outputdir="$input/objects/access/dvd" && logdir="$input/metadata/submissionDocumentation/logs" ;}; - [ -f "$input" ] && { outputdir=`dirname "$input"`"/access/dvd" && logdir="`dirname "$input"`/access/logs" ;}; - [ ! "$outputdir" ] && { outputdir="$input/objects/access/dvd" && logdir="$input/metadata/submissionDocumentation/logs" ;}; - find_input "$input" + [ "$#" != 0 ] && input="$1" + [ -d "$input" ] && { outputdir="$input/objects/access/dvd" && logdir="$input/metadata/submissionDocumentation/logs" ;}; + [ -f "$input" ] && { outputdir=`dirname "$input"`"/access/dvd" && logdir="`dirname "$input"`/access/logs" ;}; + [ ! "$outputdir" ] && { outputdir="$input/objects/access/dvd" && logdir="$input/metadata/submissionDocumentation/logs" ;}; + find_input "$input" - filename=`basename "$sourcefile"` - mediaid=`basename "$input" | cut -d. -f1` - + filename=`basename "$sourcefile"` + mediaid=`basename "$input" | cut -d. -f1` + log -b - isooutput="$outputdir/${mediaid%.*}.iso" - [ -s "$isooutput" ] && { report -wt "WARNING $isooutput already exists, skipping transcode" ; exit 1 ;}; - mkdir -p "$outputdir" - get_height "$sourcefile" - get_width "$sourcefile" - get_dar "$sourcefile" + isooutput="$outputdir/${mediaid%.*}.iso" + [ -s "$isooutput" ] && { report -wt "WARNING $isooutput already exists, skipping transcode" ; exit 1 ;}; + mkdir -p "$outputdir" + get_height "$sourcefile" + get_width "$sourcefile" + get_dar "$sourcefile" - darratio=`echo "scale=3 ; $dar" | bc` - [ `echo "scale=5 ; $darratio > 1.5" | bc -l` = 1 ] && { aspect="16/9" ; dvdaspect="16:9" ;}; - [ `echo "scale=5 ; $darratio > 1.5" | bc -l` = 1 ] || { aspect="4/3" ; dvdaspect="4:3" ;}; + darratio=`echo "scale=3 ; $dar" | bc` + [ `echo "scale=5 ; $darratio > 1.5" | bc -l` = 1 ] && { aspect="16/9" ; dvdaspect="16:9" ;}; + [ `echo "scale=5 ; $darratio > 1.5" | bc -l` = 1 ] || { aspect="4/3" ; dvdaspect="4:3" ;}; - get_maxdvdbitrate "$sourcefile" - middleoptions="-r:v ntsc -c:v mpeg2video -c:a ac3 -f dvd -s 720x480 -pix_fmt yuv420p -g 18 -b:v $MAXDVDBITRATE -maxrate 9000k -minrate 0 -bufsize 1835008 -packetsize 2048 -muxrate 10080000 -b:a 448000 -ar 48000 " - if [ "$height" -eq "486" -a "$width" -eq "720" ] ; then - middleoptions+=" -vf \"crop=720:480:0:4,setdar=${aspect}\" -aspect $aspect " - elif [ "$height" -eq "480" -a "$width" -eq "720" ] ; then - middleoptions+=" -vf \"setdar=${aspect}\" -aspect $aspect " - elif [ "$height" -eq "512" -a "$width" -eq "720" ] ; then - middleoptions+=" -vf \"crop=720:480:0:32,setdar=${aspect}\" -aspect $aspect " - else - middleoptions+=" -vf \"scale=720:480:interl=1,setdar=${aspect}\" -aspect $aspect " - fi - inputoptions+=" -y" - if [ "$logdir" != "" ] ; then - mkdir -p "$logdir" - export FFREPORT="file=${logdir}/%p_%t_$(basename $0)_${version}.txt" - inputoptions+=" -report" - fi - report -dt "Transcoding to DVD compliant mpeg2." - dvdffmpegcommand="ffmpeg $inputoptions -i \"$sourcefile\" $middleoptions \"$outputdir/${mediaid%.*}.mpeg\"" - report -dt "Running: $dvdffmpegcommand" - eval "$dvdffmpegcommand" - export VIDEO_FORMAT=NTSC - # chapters every 5 minutes, dvdauthor will ignore chapter markers greater than duration - report -dt "Making DVD VIDEO_TS folder." - dvdauthor --title -v "ntsc+${dvdaspect}" -a ac3+en -c 0,5:00,10:00,15:00,20:00,25:00,30:00,35:00,40:00,45:00,50:00,55:00,1:00:00,1:05:00,1:10:00,1:15:00,1:20:00,1:25:00,1:30:00,1:35:00,1:40:00,1:45:00,1:50:00,1:55:00,2:00:00,2:05:00,2:10:00,2:15:00,2:20:00,2:25:00,2:30:00,2:35:00,2:40:00,2:45:00,2:50:00,2:55:00,3:00:00,3:05:00,3:10:00,3:15:00,3:20:00,3:25:00,3:30:00,3:35:00,3:40:00,3:45:00,3:50:00,3:55:00 -f "$outputdir/${mediaid%.*}.mpeg" -o "$outputdir/${mediaid%.*}/" 2> "${logdir}/dvdauthor_$(get_iso8601_c)_$(basename $0)_${version}.txt" - dvdauthor_err="$?" - if [ "$dvdauthor_err" -gt "0" ] ; then - report -wt "ERROR dvdauthor reported error code $dvdauthor_err. Please review $outputdir/${mediaid%.*}/" - exit "$dvdauthor_err" - else - rm "$outputdir/${mediaid%.*}.mpeg" - fi - dvdauthor -T -o "$outputdir/${mediaid%.*}/" - volname=`echo "${DVDLABELPREFIX}${mediaid}"` - report -dt "Making DVD image file." - mkisofs -f -dvd-video -udf -V "${volname:0:32}" -v -v -o "$outputdir/${mediaid%.*}.iso" "$outputdir/${mediaid%.*}" 2> "${logdir}/mkisofs_$(get_iso8601_c)_$(basename $0)_${version}.txt" - mkisofs_err="$?" - if [ "$mkisofs_err" -gt "0" ] ; then - report -wt "ERROR mkisofs reported error code $mkisofs_err. Please review $outputdir/${mediaid%.*}.iso." - exit "$mkisofs_err" - else - rm -r "$outputdir/${mediaid%.*}/" - fi - report -dt "STATUS ${mediaid%.*}.iso is generated." - shift + get_maxdvdbitrate "$sourcefile" + middleoptions="-r:v ntsc -c:v mpeg2video -c:a ac3 -f dvd -s 720x480 -pix_fmt yuv420p -g 18 -b:v $MAXDVDBITRATE -maxrate 9000k -minrate 0 -bufsize 1835008 -packetsize 2048 -muxrate 10080000 -b:a 448000 -ar 48000 " + if [ "$height" -eq "486" -a "$width" -eq "720" ] ; then + middleoptions+=" -vf \"crop=720:480:0:4,setdar=${aspect}\" -aspect $aspect " + elif [ "$height" -eq "480" -a "$width" -eq "720" ] ; then + middleoptions+=" -vf \"setdar=${aspect}\" -aspect $aspect " + elif [ "$height" -eq "512" -a "$width" -eq "720" ] ; then + middleoptions+=" -vf \"crop=720:480:0:32,setdar=${aspect}\" -aspect $aspect " + else + middleoptions+=" -vf \"scale=720:480:interl=1,setdar=${aspect}\" -aspect $aspect " + fi + inputoptions+=" -y" + if [ "$logdir" != "" ] ; then + mkdir -p "$logdir" + export FFREPORT="file=${logdir}/%p_%t_$(basename $0)_${version}.txt" + inputoptions+=" -report" + fi + report -dt "Transcoding to DVD compliant mpeg2." + dvdffmpegcommand="ffmpeg $inputoptions -i \"$sourcefile\" $middleoptions \"$outputdir/${mediaid%.*}.mpeg\"" + report -dt "Running: $dvdffmpegcommand" + eval "$dvdffmpegcommand" + export VIDEO_FORMAT=NTSC + # chapters every 5 minutes, dvdauthor will ignore chapter markers greater than duration + report -dt "Making DVD VIDEO_TS folder." + dvdauthor --title -v "ntsc+${dvdaspect}" -a ac3+en -c 0,5:00,10:00,15:00,20:00,25:00,30:00,35:00,40:00,45:00,50:00,55:00,1:00:00,1:05:00,1:10:00,1:15:00,1:20:00,1:25:00,1:30:00,1:35:00,1:40:00,1:45:00,1:50:00,1:55:00,2:00:00,2:05:00,2:10:00,2:15:00,2:20:00,2:25:00,2:30:00,2:35:00,2:40:00,2:45:00,2:50:00,2:55:00,3:00:00,3:05:00,3:10:00,3:15:00,3:20:00,3:25:00,3:30:00,3:35:00,3:40:00,3:45:00,3:50:00,3:55:00 -f "$outputdir/${mediaid%.*}.mpeg" -o "$outputdir/${mediaid%.*}/" 2> "${logdir}/dvdauthor_$(get_iso8601_c)_$(basename $0)_${version}.txt" + dvdauthor_err="$?" + if [ "$dvdauthor_err" -gt "0" ] ; then + report -wt "ERROR dvdauthor reported error code $dvdauthor_err. Please review $outputdir/${mediaid%.*}/" + exit "$dvdauthor_err" + else + rm "$outputdir/${mediaid%.*}.mpeg" + fi + dvdauthor -T -o "$outputdir/${mediaid%.*}/" + volname=`echo "${DVDLABELPREFIX}${mediaid}"` + report -dt "Making DVD image file." + mkisofs -f -dvd-video -udf -V "${volname:0:32}" -v -v -o "$outputdir/${mediaid%.*}.iso" "$outputdir/${mediaid%.*}" 2> "${logdir}/mkisofs_$(get_iso8601_c)_$(basename $0)_${version}.txt" + mkisofs_err="$?" + if [ "$mkisofs_err" -gt "0" ] ; then + report -wt "ERROR mkisofs reported error code $mkisofs_err. Please review $outputdir/${mediaid%.*}.iso." + exit "$mkisofs_err" + else + rm -r "$outputdir/${mediaid%.*}/" + fi + report -dt "STATUS ${mediaid%.*}.iso is generated." + shift done log -e diff --git a/makeframes b/makeframes index aafab474..3179539b 100755 --- a/makeframes +++ b/makeframes @@ -12,19 +12,19 @@ find_input "$1" [ ! "$file" ] && outputdir="$1/objects/access/images" - filename=`basename "$file"` + filename=`basename "$file"` mediaid=`basename "$1" | cut -d. -f1` if [ ! -s "$outputdir/${mediaid%.*}.mp4" ] ; then - IMAGECOUNT=10 - INPUT="$1" - BASE=`basename $file` - DURATION=`ffprobe 2>/dev/null $file -show_format | grep duration | cut -d= -f2` - mkdir -p "$outputdir" - for IMAGENUMBER in `seq 1 "$IMAGECOUNT"` ; do - START=`echo "( $DURATION / ( $IMAGECOUNT + 1 )) * $IMAGENUMBER" | bc` - ffmpeg -ss "$START" -i $file -vf yadif,thumbnail=100 -frames:v 1 "$outputdir/${BASE%.*}_${IMAGENUMBER}.tiff" - done - fi - shift + IMAGECOUNT=10 + INPUT="$1" + BASE=`basename $file` + DURATION=`ffprobe 2>/dev/null $file -show_format | grep duration | cut -d= -f2` + mkdir -p "$outputdir" + for IMAGENUMBER in `seq 1 "$IMAGECOUNT"` ; do + START=`echo "( $DURATION / ( $IMAGECOUNT + 1 )) * $IMAGENUMBER" | bc` + ffmpeg -ss "$START" -i $file -vf yadif,thumbnail=100 -frames:v 1 "$outputdir/${BASE%.*}_${IMAGENUMBER}.tiff" + done + fi + shift done \ No newline at end of file diff --git a/makelossless b/makelossless index 7e861b3b..57bf5b4b 100755 --- a/makelossless +++ b/makelossless @@ -5,72 +5,72 @@ scriptdir=`dirname "$0"` check_dependencies ffmpeg muxmovie mediainfo cleanup(){ - log -a "Process aborted" - exit 1 + log -a "Process aborted" + exit 1 } trap cleanup SIGHUP SIGINT SIGTERM log -b while [ "$*" != "" ] ; do - file="$1" - filename=`basename "$file"` - dirname=`dirname "$file"` - - [ "$#" != 0 ] && input="$1" - [ -d "$input" ] && { outputdir="$input/objects" && logdir="$input/metadata/submissionDocumentation/logs" ;}; - [ -f "$input" ] && { outputdir=`dirname "$input"`"/lossless" && logdir="`dirname "$input"`/lossless/logs" ;}; - [ ! "$outputdir" ] && { outputdir="$input/objects" && logdir="$input/metadata/submissionDocumentation/logs" ;}; - - [ -d "$input" ] && sourcefile=`find "$1/objects" -maxdepth 1 -mindepth 1 -type f \( -name "*.mov" -o -name "*.mxf" -o -name "*.mp4" -o -name "*.dv" \) ! -name ".*"` - [ -f "$input" ] && sourcefile="$input" - - get_codectagstring "$sourcefile" - if [ "$codec_tag_string" == "2vuy" ] ; then - echo "$filename is 2vuy, starting encode" - mkdir -p "$outputdir" "$logdir" - export FFREPORT="file=${logdir}/%p_%t_convert-to-ffv1.log" - ffmpeg -report -vsync 0 -i "$sourcefile" -map 0:v -map 0:a -c:v ffv1 -g 1 -c:a copy "$outputdir/${filename%.*}_ffv1.mov" -f framemd5 -an "$logdir/${filename%.*}.framemd5" - ffmpeg_ffv1_err="$?" - [ "$ffmpeg_ffv1_err" -gt 0 ] && echo ffmpeg ended with error && exit 1 - ffmpeg -i "$outputdir/${filename%.*}_ffv1.mov" -f framemd5 -pix_fmt uyvy422 -an "$logdir/${filename%.*}_ffv1.framemd5" - ffmpeg_md5_err="$?" - [ "$ffmpeg_md5_err" -gt 0 ] && echo ffmpeg md5 ended with error && exit 1 - muxmovie "$sourcefile" -track "Timecode Track" -track "Closed Caption Track" -self-contained -o "$outputdir/${filename%.*}_tc_e608.mov" - muxmovie_err="$?" - [ "$muxmovie_err" -gt 0 ] && echo muxmovie ended with error && exit 1 - if [ `md5 -q "$logdir/${filename%.*}.framemd5"` = `md5 -q "$logdir/${filename%.*}_ffv1.framemd5"` ] ; then - echo Everything looks safe. Going to delete the original. - mediainfo -f --language=raw --output=XML "$sourcefile" > "$logdir/${filename%.*}_mediainfo.xml" - #rm -f -v "$sourcefile" - else - echo Not looking safe. Going to keep the original. - fi - elif [ "$codec_tag_string" == "v210" ] ; then - echo "$filename is v210, starting encode" - mkdir -p "$outputdir" "$logdir" - export FFREPORT="file=${logdir}/%p_%t_convert-to-ffv1.log" - ffmpeg -report -vsync 0 -i "$sourcefile" -map 0:v -map 0:a -c:v ffv1 -g 1 -c:a copy "$outputdir/${filename%.*}_ffv1.mov" -f framemd5 -an "$logdir/${filename%.*}.framemd5" - ffmpeg_ffv1_err="$?" - [ "$ffmpeg_ffv1_err" -gt 0 ] && echo ffmpeg ended with error && exit 1 - ffmpeg -i "$outputdir/${filename%.*}_ffv1.mov" -f framemd5 -an "$logdir/${filename%.*}_ffv1.framemd5" - ffmpeg_md5_err="$?" - [ "$ffmpeg_md5_err" -gt 0 ] && echo ffmpeg md5 ended with error && exit 1 - muxmovie "$sourcefile" -track "Timecode Track" -track "Closed Caption Track" -self-contained -o "$outputdir/${filename%.*}_tc_e608.mov" - muxmovie_err="$?" - [ "$muxmovie_err" -gt 0 ] && echo muxmovie ended with error && exit 1 - if [ `md5 -q "$logdir/${filename%.*}.framemd5"` = `md5 -q "$logdir/${filename%.*}_ffv1.framemd5"` ] ; then - echo Everything looks safe. Going to delete the original. - mediainfo -f --language=raw --output=XML "$sourcefile" > "$logdir/${filename%.*}_mediainfo.xml" - #rm -f -v "$sourcefile" - else - echo Not looking safe. Going to keep the original. - fi - else - echo "$filename is not 2vuy or v210, quitting" - exit 1 - fi - echo done with "$sourcefile" - shift + file="$1" + filename=`basename "$file"` + dirname=`dirname "$file"` + + [ "$#" != 0 ] && input="$1" + [ -d "$input" ] && { outputdir="$input/objects" && logdir="$input/metadata/submissionDocumentation/logs" ;}; + [ -f "$input" ] && { outputdir=`dirname "$input"`"/lossless" && logdir="`dirname "$input"`/lossless/logs" ;}; + [ ! "$outputdir" ] && { outputdir="$input/objects" && logdir="$input/metadata/submissionDocumentation/logs" ;}; + + [ -d "$input" ] && sourcefile=`find "$1/objects" -maxdepth 1 -mindepth 1 -type f \( -name "*.mov" -o -name "*.mxf" -o -name "*.mp4" -o -name "*.dv" \) ! -name ".*"` + [ -f "$input" ] && sourcefile="$input" + + get_codectagstring "$sourcefile" + if [ "$codec_tag_string" == "2vuy" ] ; then + echo "$filename is 2vuy, starting encode" + mkdir -p "$outputdir" "$logdir" + export FFREPORT="file=${logdir}/%p_%t_convert-to-ffv1.log" + ffmpeg -report -vsync 0 -i "$sourcefile" -map 0:v -map 0:a -c:v ffv1 -g 1 -c:a copy "$outputdir/${filename%.*}_ffv1.mov" -f framemd5 -an "$logdir/${filename%.*}.framemd5" + ffmpeg_ffv1_err="$?" + [ "$ffmpeg_ffv1_err" -gt 0 ] && echo ffmpeg ended with error && exit 1 + ffmpeg -i "$outputdir/${filename%.*}_ffv1.mov" -f framemd5 -pix_fmt uyvy422 -an "$logdir/${filename%.*}_ffv1.framemd5" + ffmpeg_md5_err="$?" + [ "$ffmpeg_md5_err" -gt 0 ] && echo ffmpeg md5 ended with error && exit 1 + muxmovie "$sourcefile" -track "Timecode Track" -track "Closed Caption Track" -self-contained -o "$outputdir/${filename%.*}_tc_e608.mov" + muxmovie_err="$?" + [ "$muxmovie_err" -gt 0 ] && echo muxmovie ended with error && exit 1 + if [ `md5 -q "$logdir/${filename%.*}.framemd5"` = `md5 -q "$logdir/${filename%.*}_ffv1.framemd5"` ] ; then + echo Everything looks safe. Going to delete the original. + mediainfo -f --language=raw --output=XML "$sourcefile" > "$logdir/${filename%.*}_mediainfo.xml" + #rm -f -v "$sourcefile" + else + echo Not looking safe. Going to keep the original. + fi + elif [ "$codec_tag_string" == "v210" ] ; then + echo "$filename is v210, starting encode" + mkdir -p "$outputdir" "$logdir" + export FFREPORT="file=${logdir}/%p_%t_convert-to-ffv1.log" + ffmpeg -report -vsync 0 -i "$sourcefile" -map 0:v -map 0:a -c:v ffv1 -g 1 -c:a copy "$outputdir/${filename%.*}_ffv1.mov" -f framemd5 -an "$logdir/${filename%.*}.framemd5" + ffmpeg_ffv1_err="$?" + [ "$ffmpeg_ffv1_err" -gt 0 ] && echo ffmpeg ended with error && exit 1 + ffmpeg -i "$outputdir/${filename%.*}_ffv1.mov" -f framemd5 -an "$logdir/${filename%.*}_ffv1.framemd5" + ffmpeg_md5_err="$?" + [ "$ffmpeg_md5_err" -gt 0 ] && echo ffmpeg md5 ended with error && exit 1 + muxmovie "$sourcefile" -track "Timecode Track" -track "Closed Caption Track" -self-contained -o "$outputdir/${filename%.*}_tc_e608.mov" + muxmovie_err="$?" + [ "$muxmovie_err" -gt 0 ] && echo muxmovie ended with error && exit 1 + if [ `md5 -q "$logdir/${filename%.*}.framemd5"` = `md5 -q "$logdir/${filename%.*}_ffv1.framemd5"` ] ; then + echo Everything looks safe. Going to delete the original. + mediainfo -f --language=raw --output=XML "$sourcefile" > "$logdir/${filename%.*}_mediainfo.xml" + #rm -f -v "$sourcefile" + else + echo Not looking safe. Going to keep the original. + fi + else + echo "$filename is not 2vuy or v210, quitting" + exit 1 + fi + echo done with "$sourcefile" + shift done log -e diff --git a/makemetadata b/makemetadata index 56c70e0e..449d9bf5 100755 --- a/makemetadata +++ b/makemetadata @@ -6,30 +6,30 @@ scriptdir=`dirname "$0"` . "$scriptdir/mmfunctions" || { echo "Missing '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;}; cleanup(){ - log -a "Process aborted" - exit 1 + log -a "Process aborted" + exit 1 } trap cleanup SIGHUP SIGINT SIGTERM usage(){ - echo - echo "$(basename $0) ${version}" - echo "This script may be run interactively by running it with no arguments or may be used with the following options." - echo "Usage: $(basename $0) [ -m mediaid ]" - echo " -m mediaid" - exit + echo + echo "$(basename $0) ${version}" + echo "This script may be run interactively by running it with no arguments or may be used with the following options." + echo "Usage: $(basename $0) [ -m mediaid ]" + echo " -m mediaid" + exit } # command-line options to set mediaid and original variables OPTIND=1 while getopts ":hm:" opt; do - case "$opt" in - h) usage ;; - m) mediaid="$OPTARG" ;; - \?) echo "Invalid option: -$OPTARG" ; exit 1 ;; - :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; - esac + case "$opt" in + h) usage ;; + m) mediaid="$OPTARG" ;; + \?) echo "Invalid option: -$OPTARG" ; exit 1 ;; + :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; + esac done shift $(( ${OPTIND} - 1 )) @@ -37,55 +37,55 @@ log -b counter=0 while [ "$*" != "" ] ; do - uuid=`uuidgen` - - cd "$1" - objects_file=`find "./objects" -maxdepth 1 -mindepth 1 -type f -name "*.mov" ! -name ".*"` - service_file=`find "./objects/service" -maxdepth 1 -mindepth 1 -type f -name "*.mov" ! -name ".*"` - mkdir -p "/tmp/$uuid" - - outputdir="./metadata/submissionDocumentation/fileMeta" - mkdir -p "$outputdir" - - objectbasename=`basename "$objects_file"` - servicebasename=`basename "$service_file"` - mediaid=`basename "$1" | cut -d. -f1` - - find "./objects/access" -type d -mindepth 1 -maxdepth 1 > "/tmp/$uuid/access.txt" - while read access ; do - accessname=`basename "$access"` - find "$access" -type f ! -name ".*" > "/tmp/$uuid/access_${accessname}.txt" - while read access_file ; do - mkdir -p "$outputdir/access/$accessname" - accessbasename=`basename "$access_file"` - ffprobe 2>/dev/null "$access_file" -show_format -show_streams -show_data -show_error -show_versions -noprivate -of xml="q=1:x=1" > "$outputdir/access/$accessname/${accessbasename%.*}_ffprobe.xml" - ffprobe 2>/dev/null "$access_file" -show_format -show_streams -show_data -show_error -show_versions -of json > "$outputdir/access/$accessname/${accessbasename%.*}_ffprobe.json" - mediainfo --language=raw -f --output=XML "$access_file" > "$outputdir/access/$accessname/${accessbasename%.*}_mediainfo.xml" - done < "/tmp/$uuid/access_${accessname}.txt" - done < "/tmp/$uuid/access.txt" - - outputdir="./metadata/submissionDocumentation/fileMeta" - mkdir -p "$outputdir" - - objectbasename=`basename "$objects_file"` - servicebasename=`basename "$service_file"` - mediaid=`basename "$1" | cut -d. -f1` - - # transcode - report -dt "STATUS Making metadata reports." - - #only works with one file in objects , to do - mkdir -p "$outputdir/objects" - ffprobe 2>/dev/null "$objects_file" -show_format -show_streams -show_data -show_error -show_versions -noprivate -of xml="q=1:x=1" > "$outputdir/objects/${objectbasename%.*}_ffprobe.xml" - ffprobe 2>/dev/null "$objects_file" -show_format -show_streams -show_data -show_error -show_versions -of json > "$outputdir/objects/${objectbasename%.*}_ffprobe.json" - mediainfo --language=raw -f --output=XML "$objects_file" > "$outputdir/objects/${objectbasename%.*}_mediainfo.xml" - - mkdir -p "$outputdir/service" - ffprobe 2>/dev/null "$service_file" -show_format -show_streams -show_data -show_error -show_versions -noprivate -of xml="q=1:x=1" > "$outputdir/service/${servicebasename%.*}_ffprobe.xml" - ffprobe 2>/dev/null "$service_file" -show_format -show_streams -show_data -show_error -show_versions -of json > "$outputdir/service/${servicebasename%.*}_ffprobe.json" - mediainfo --language=raw -f --output=XML "$service_file" > "$outputdir/service/${servicebasename%.*}_mediainfo.xml" - rm -r -f "/tmp/$uuid" - shift - counter=`expr "$counter" + 1` + uuid=`uuidgen` + + cd "$1" + objects_file=`find "./objects" -maxdepth 1 -mindepth 1 -type f -name "*.mov" ! -name ".*"` + service_file=`find "./objects/service" -maxdepth 1 -mindepth 1 -type f -name "*.mov" ! -name ".*"` + mkdir -p "/tmp/$uuid" + + outputdir="./metadata/submissionDocumentation/fileMeta" + mkdir -p "$outputdir" + + objectbasename=`basename "$objects_file"` + servicebasename=`basename "$service_file"` + mediaid=`basename "$1" | cut -d. -f1` + + find "./objects/access" -type d -mindepth 1 -maxdepth 1 > "/tmp/$uuid/access.txt" + while read access ; do + accessname=`basename "$access"` + find "$access" -type f ! -name ".*" > "/tmp/$uuid/access_${accessname}.txt" + while read access_file ; do + mkdir -p "$outputdir/access/$accessname" + accessbasename=`basename "$access_file"` + ffprobe 2>/dev/null "$access_file" -show_format -show_streams -show_data -show_error -show_versions -noprivate -of xml="q=1:x=1" > "$outputdir/access/$accessname/${accessbasename%.*}_ffprobe.xml" + ffprobe 2>/dev/null "$access_file" -show_format -show_streams -show_data -show_error -show_versions -of json > "$outputdir/access/$accessname/${accessbasename%.*}_ffprobe.json" + mediainfo --language=raw -f --output=XML "$access_file" > "$outputdir/access/$accessname/${accessbasename%.*}_mediainfo.xml" + done < "/tmp/$uuid/access_${accessname}.txt" + done < "/tmp/$uuid/access.txt" + + outputdir="./metadata/submissionDocumentation/fileMeta" + mkdir -p "$outputdir" + + objectbasename=`basename "$objects_file"` + servicebasename=`basename "$service_file"` + mediaid=`basename "$1" | cut -d. -f1` + + # transcode + report -dt "STATUS Making metadata reports." + + #only works with one file in objects , to do + mkdir -p "$outputdir/objects" + ffprobe 2>/dev/null "$objects_file" -show_format -show_streams -show_data -show_error -show_versions -noprivate -of xml="q=1:x=1" > "$outputdir/objects/${objectbasename%.*}_ffprobe.xml" + ffprobe 2>/dev/null "$objects_file" -show_format -show_streams -show_data -show_error -show_versions -of json > "$outputdir/objects/${objectbasename%.*}_ffprobe.json" + mediainfo --language=raw -f --output=XML "$objects_file" > "$outputdir/objects/${objectbasename%.*}_mediainfo.xml" + + mkdir -p "$outputdir/service" + ffprobe 2>/dev/null "$service_file" -show_format -show_streams -show_data -show_error -show_versions -noprivate -of xml="q=1:x=1" > "$outputdir/service/${servicebasename%.*}_ffprobe.xml" + ffprobe 2>/dev/null "$service_file" -show_format -show_streams -show_data -show_error -show_versions -of json > "$outputdir/service/${servicebasename%.*}_ffprobe.json" + mediainfo --language=raw -f --output=XML "$service_file" > "$outputdir/service/${servicebasename%.*}_mediainfo.xml" + rm -r -f "/tmp/$uuid" + shift + counter=`expr "$counter" + 1` done log -e diff --git a/makepodcast b/makepodcast index 19adccfe..2013d4f4 100755 --- a/makepodcast +++ b/makepodcast @@ -7,32 +7,32 @@ scriptdir=`dirname "$0"` . "$scriptdir/mmfunctions" || { echo "Missing '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;}; cleanup(){ - log -a "Process aborted" - exit 1 + log -a "Process aborted" + exit 1 } trap cleanup SIGHUP SIGINT SIGTERM usage(){ - echo - echo "$(basename $0) ${version}" - echo "This script may be run interactively by running it with no arguments or may be used with the following options." - echo "Usage: $(basename $0) [ -m mediaid ] [ -f sourcefile ]" - echo " -m mediaid" - echo " -f sourcefile" - exit + echo + echo "$(basename $0) ${version}" + echo "This script may be run interactively by running it with no arguments or may be used with the following options." + echo "Usage: $(basename $0) [ -m mediaid ] [ -f sourcefile ]" + echo " -m mediaid" + echo " -f sourcefile" + exit } # command-line options to set mediaid and original variables OPTIND=1 while getopts ":hm:f:" opt; do - case "$opt" in - h) usage ;; - m) mediaid="$OPTARG";; - f) input="$OPTARG" ; once="y" ;; - \?) echo "Invalid option: -$OPTARG" ; exit 1 ;; - :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; - esac + case "$opt" in + h) usage ;; + m) mediaid="$OPTARG";; + f) input="$OPTARG" ; once="y" ;; + \?) echo "Invalid option: -$OPTARG" ; exit 1 ;; + :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; + esac done shift $(( ${OPTIND} - 1 )) @@ -40,30 +40,30 @@ shift $(( ${OPTIND} - 1 )) [ "$#" = 0 -a ! "$input" ] && { ask_input ; once="y" ;}; while [ "$*" != "" -o "$once" = "y" ] ; do - once="n" - [ "$#" != 0 ] && input="$1" - [ -d "$input" ] && { outputdir="$input/objects/access/podcast" && logdir="$input/metadata/submissionDocumentation/logs" ;}; - [ -f "$input" ] && { outputdir=`dirname "$input"`"/access/podcast" && logdir="`dirname "$input"`/access/logs" ;}; - [ ! "$outputdir" ] && { outputdir="$input/objects/access/podcast" && logdir="$input/metadata/submissionDocumentation/logs" ;}; - find_input "$input" + once="n" + [ "$#" != 0 ] && input="$1" + [ -d "$input" ] && { outputdir="$input/objects/access/podcast" && logdir="$input/metadata/submissionDocumentation/logs" ;}; + [ -f "$input" ] && { outputdir=`dirname "$input"`"/access/podcast" && logdir="`dirname "$input"`/access/logs" ;}; + [ ! "$outputdir" ] && { outputdir="$input/objects/access/podcast" && logdir="$input/metadata/submissionDocumentation/logs" ;}; + find_input "$input" - filename=`basename "$sourcefile"` - mediaid=`basename "$input" | cut -d. -f1` - + filename=`basename "$sourcefile"` + mediaid=`basename "$input" | cut -d. -f1` + log -b - podcastoutput="$outputdir/${mediaid%.*}_podcast.mov" - [ -s "$podcastoutput" ] && { report -wt "WARNING $podcastoutput already exists, skipping transcode" ; exit 1 ;}; - mkdir -p "$outputdir" - middleoptions="-movflags faststart -pix_fmt yuv420p -c:v libx264 -b:v 1500k -maxrate:v 3000k -minrate:v 375k -bufsize:v 6000k -vf 'yadif,scale=640:trunc(ow/dar/2)*2:interl=1' -c:a libfaac -b:a 96k " - if [ "$logdir" != "" ] ; then - mkdir -p "$logdir" - export FFREPORT="file=${logdir}/%p_%t_$(basename $0)_${version}.txt" - inputoptions+=" -report" - fi - makepodcastcommand="ffmpeg $inputoptions -i \"$sourcefile\" $middleoptions \"$podcastoutput\"" - report -dt "Running: $makepodcastcommand" - eval "$makepodcastcommand" - shift + podcastoutput="$outputdir/${mediaid%.*}_podcast.mov" + [ -s "$podcastoutput" ] && { report -wt "WARNING $podcastoutput already exists, skipping transcode" ; exit 1 ;}; + mkdir -p "$outputdir" + middleoptions="-movflags faststart -pix_fmt yuv420p -c:v libx264 -b:v 1500k -maxrate:v 3000k -minrate:v 375k -bufsize:v 6000k -vf 'yadif,scale=640:trunc(ow/dar/2)*2:interl=1' -c:a libfaac -b:a 96k " + if [ "$logdir" != "" ] ; then + mkdir -p "$logdir" + export FFREPORT="file=${logdir}/%p_%t_$(basename $0)_${version}.txt" + inputoptions+=" -report" + fi + makepodcastcommand="ffmpeg $inputoptions -i \"$sourcefile\" $middleoptions \"$podcastoutput\"" + report -dt "Running: $makepodcastcommand" + eval "$makepodcastcommand" + shift done log -e diff --git a/makeyoutube b/makeyoutube index 3bd4a656..175eade8 100755 --- a/makeyoutube +++ b/makeyoutube @@ -7,32 +7,32 @@ scriptdir=`dirname "$0"` . "$scriptdir/mmfunctions" || { echo "Missing '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;}; cleanup(){ - log -a "Process aborted" - exit 1 + log -a "Process aborted" + exit 1 } trap cleanup SIGHUP SIGINT SIGTERM usage(){ - echo - echo "$(basename $0) ${version}" - echo "This script may be run interactively by running it with no arguments or may be used with the following options." - echo "Usage: $(basename $0) [ -m mediaid ] [ -f sourcefile ]" - echo " -m mediaid" - echo " -f sourcefile" - exit + echo + echo "$(basename $0) ${version}" + echo "This script may be run interactively by running it with no arguments or may be used with the following options." + echo "Usage: $(basename $0) [ -m mediaid ] [ -f sourcefile ]" + echo " -m mediaid" + echo " -f sourcefile" + exit } # command-line options to set mediaid and original variables OPTIND=1 while getopts ":hm:f:" opt; do - case "$opt" in - h) usage ;; - m) mediaid="$OPTARG";; - f) input="$OPTARG" ; once="y" ;; - \?) echo "Invalid option: -$OPTARG" ; exit 1 ;; - :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; - esac + case "$opt" in + h) usage ;; + m) mediaid="$OPTARG";; + f) input="$OPTARG" ; once="y" ;; + \?) echo "Invalid option: -$OPTARG" ; exit 1 ;; + :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; + esac done shift $(( ${OPTIND} - 1 )) @@ -40,60 +40,60 @@ shift $(( ${OPTIND} - 1 )) [ "$#" = 0 -a ! "$input" ] && { ask_input ; once="y" ;}; while [ "$*" != "" -o "$once" = "y" ] ; do - once="n" - [ "$#" != 0 ] && input="$1" - [ -d "$input" ] && { outputdir="$input/objects/access/youtube_up" && logdir="$input/metadata/submissionDocumentation/logs" ;}; - [ -f "$input" ] && { outputdir=`dirname "$input"`"/access/youtube_up" && logdir="`dirname "$input"`/access/logs" ;}; - [ ! "$outputdir" ] && { outputdir="$input/objects/access/youtube_up" && logdir="$input/metadata/submissionDocumentation/logs" ;}; - find_input "$input" + once="n" + [ "$#" != 0 ] && input="$1" + [ -d "$input" ] && { outputdir="$input/objects/access/youtube_up" && logdir="$input/metadata/submissionDocumentation/logs" ;}; + [ -f "$input" ] && { outputdir=`dirname "$input"`"/access/youtube_up" && logdir="`dirname "$input"`/access/logs" ;}; + [ ! "$outputdir" ] && { outputdir="$input/objects/access/youtube_up" && logdir="$input/metadata/submissionDocumentation/logs" ;}; + find_input "$input" - filename=`basename "$sourcefile"` - mediaid=`basename "$1" | cut -d. -f1` - + filename=`basename "$sourcefile"` + mediaid=`basename "$1" | cut -d. -f1` + log -b - youtubeoutput="$outputdir/${mediaid%.*}.mp4" - [ -s "$youtubeoutput" ] && { report -wt "WARNING $youtubeoutput already exists, skipping transcode" ; exit 1 ;}; - mkdir -p "$outputdir" - get_height "$sourcefile" - get_width "$sourcefile" + youtubeoutput="$outputdir/${mediaid%.*}.mp4" + [ -s "$youtubeoutput" ] && { report -wt "WARNING $youtubeoutput already exists, skipping transcode" ; exit 1 ;}; + mkdir -p "$outputdir" + get_height "$sourcefile" + get_width "$sourcefile" - inputoptions="" - inputoptions+=" -vsync 0" - middleoptions="" - middleoptions+=" -movflags faststart" - middleoptions+=" -pix_fmt yuv420p" - middleoptions+=" -c:v libx264" - middleoptions+=" -crf 18" - if [ "$height" -eq "486" -a "$width" -eq "720" ] ; then - middleoptions+=" -vf \"crop=720:480:0:4,yadif\" " - elif [ "$height" -eq "512" -a "$width" -eq "720" ] ;then - middleoptions+=" -vf \"crop=720:480:0:32,yadif\" " - else - middleoptions+=" -vf yadif " - fi - middleoptions+=" -c:a libfaac" - middleoptions+=" -b:a 128k" - middleoptions+=" -f mp4" + inputoptions="" + inputoptions+=" -vsync 0" + middleoptions="" + middleoptions+=" -movflags faststart" + middleoptions+=" -pix_fmt yuv420p" + middleoptions+=" -c:v libx264" + middleoptions+=" -crf 18" + if [ "$height" -eq "486" -a "$width" -eq "720" ] ; then + middleoptions+=" -vf \"crop=720:480:0:4,yadif\" " + elif [ "$height" -eq "512" -a "$width" -eq "720" ] ;then + middleoptions+=" -vf \"crop=720:480:0:32,yadif\" " + else + middleoptions+=" -vf yadif " + fi + middleoptions+=" -c:a libfaac" + middleoptions+=" -b:a 128k" + middleoptions+=" -f mp4" - if [ "$logdir" != "" ] ; then - mkdir -p "$logdir" - export FFREPORT="file=${logdir}/%p_%t_$(basename $0)_${version}.txt" - inputoptions+=" -report" - fi - #makeyoutubecommand="ffmpeg $inputoptions -i \"$sourcefile\" $middleoptions \"$youtubeoutput\"" - #report -dt "Running: $makeyoutubecommand" - #eval "$makeyoutubecommand" - #chapterlist=$(ffmpeg -i "$sourcefile" 2>&1 | grep "Chapter #0." | awk '{print $4}' | tr -d "\n" | sed '$s/.$//') && { chaptered="Y" ; report "Found chapters found in $sourcefile" ;}; - #if [ chaptered="Y" ] ; then - #if [ "$logdir" != "" ] ; then - #export FFREPORT="file=${logdir}/%p_%t_$(basename $0)_segmented_${version}.txt" - #fi - #-force_key_frames $chapterlist - #segmentcommand="ffmpeg $inputoptions -i \"$sourcefile\" $middleoptions -r:v ntsc -map 0:v -map 0:a -f segment -segment_times $chapterlist -reset_timestamps 1 #-segment_start_number 1 -segment_time_delta 0.05 \"${youtubeoutput%.*}_S%02d.mp4\"" - #report -dt "Running: $segmentcommand" - #eval "$segmentcommand" - #fi - shift + if [ "$logdir" != "" ] ; then + mkdir -p "$logdir" + export FFREPORT="file=${logdir}/%p_%t_$(basename $0)_${version}.txt" + inputoptions+=" -report" + fi + #makeyoutubecommand="ffmpeg $inputoptions -i \"$sourcefile\" $middleoptions \"$youtubeoutput\"" + #report -dt "Running: $makeyoutubecommand" + #eval "$makeyoutubecommand" + #chapterlist=$(ffmpeg -i "$sourcefile" 2>&1 | grep "Chapter #0." | awk '{print $4}' | tr -d "\n" | sed '$s/.$//') && { chaptered="Y" ; report "Found chapters found in $sourcefile" ;}; + #if [ chaptered="Y" ] ; then + #if [ "$logdir" != "" ] ; then + #export FFREPORT="file=${logdir}/%p_%t_$(basename $0)_segmented_${version}.txt" + #fi + #-force_key_frames $chapterlist + #segmentcommand="ffmpeg $inputoptions -i \"$sourcefile\" $middleoptions -r:v ntsc -map 0:v -map 0:a -f segment -segment_times $chapterlist -reset_timestamps 1 #-segment_start_number 1 -segment_time_delta 0.05 \"${youtubeoutput%.*}_S%02d.mp4\"" + #report -dt "Running: $segmentcommand" + #eval "$segmentcommand" + #fi + shift done log -e diff --git a/mmfunctions b/mmfunctions index c3a82a42..addd6051 100755 --- a/mmfunctions +++ b/mmfunctions @@ -9,270 +9,270 @@ get_iso8601_c(){ } log(){ - logfile="$HOME/Library/Logs/mediamicroservices.log" - OPTIND=1 - while getopts ":beac" opt; do - case "$opt" in - b) status="start" ;; # script is beginning - e) status="end" ;; # script is ending - a) status="abort" ;; # script is aborted - c) status="comment" ;; # comment about what script is doing - esac - done - shift $(( ${OPTIND} - 1 )) - note="$1" - echo `get_iso8601`", $(basename $0), $status, $op, $mediaid, $note" >> "$logfile" + logfile="$HOME/Library/Logs/mediamicroservices.log" + OPTIND=1 + while getopts ":beac" opt; do + case "$opt" in + b) status="start" ;; # script is beginning + e) status="end" ;; # script is ending + a) status="abort" ;; # script is aborted + c) status="comment" ;; # comment about what script is doing + esac + done + shift $(( ${OPTIND} - 1 )) + note="$1" + echo `get_iso8601`", $(basename $0), $status, $op, $mediaid, $note" >> "$logfile" } report(){ - local RED="$(tput setaf 1)" # Red - For Warnings - local GREEN="$(tput setaf 2)" # Green - For Declarations - local BLUE="$(tput setaf 4)" # Blue - For Questions - local NC="$(tput sgr0)" # No Color - local color="" - local startmessage="" - local endmessage="" - local echoopt="" - OPTIND=1 - while getopts ":qdwtsn" opt; do - case "$opt" in - q) color="$BLUE" ;; # question mode, use color blue - d) color="$GREEN" ;; # declaration mode, use color green - w) color="$RED" ; log="Y";; # warning mode, use color red - t) startmessage="$(get_iso8601) - " ;; # prepend timestamp to the message - s) startmessage+="[$(basename $0)] " ;; # prepend scriptname to the message - n) echoopt="-n" ;; # to avoid line breaks after echo - esac - done - shift $(( ${OPTIND} - 1 )) - message="$1" - echo $echoopt "${color}${startmessage}${message}${NC}" - [ "$log" = "Y" ] && log -c "$message" + local RED="$(tput setaf 1)" # Red - For Warnings + local GREEN="$(tput setaf 2)" # Green - For Declarations + local BLUE="$(tput setaf 4)" # Blue - For Questions + local NC="$(tput sgr0)" # No Color + local color="" + local startmessage="" + local endmessage="" + local echoopt="" + OPTIND=1 + while getopts ":qdwtsn" opt; do + case "$opt" in + q) color="$BLUE" ;; # question mode, use color blue + d) color="$GREEN" ;; # declaration mode, use color green + w) color="$RED" ; log="Y";; # warning mode, use color red + t) startmessage="$(get_iso8601) - " ;; # prepend timestamp to the message + s) startmessage+="[$(basename $0)] " ;; # prepend scriptname to the message + n) echoopt="-n" ;; # to avoid line breaks after echo + esac + done + shift $(( ${OPTIND} - 1 )) + message="$1" + echo $echoopt "${color}${startmessage}${message}${NC}" + [ "$log" = "Y" ] && log -c "$message" } black_at_ends(){ - input_movie="$1" - name=`basename "$input_movie"` - analysis_head_seconds=10 - analysis_tail_seconds=10 - report -dt "Analyzing $name for excessive black at head or tail." - duration=`ffprobe "$1" -show_format 2> /dev/null | grep duration | cut -d= -f2 | cut -d. -f1` - tail_start=`echo "$duration - $analysis_tail_seconds" | bc` - head_black=`ffmpeg -t "$analysis_head_seconds" -i "$1" -an -vf blackdetect=pix_th=0.05 -loglevel debug -f null - 2>&1 | grep -c -o picture_black_ratio:1` - report -dt "Black frames in first $analysis_head_seconds seconds: $head_black." - tail_black=`ffmpeg -ss "$tail_start" -i "$1" -an -vf blackdetect=pix_th=0.05 -loglevel debug -f null - 2>&1 | grep -c -o picture_black_ratio:1` - report -dt "Black frames in last $analysis_head_seconds seconds: $tail_black." + input_movie="$1" + name=`basename "$input_movie"` + analysis_head_seconds=10 + analysis_tail_seconds=10 + report -dt "Analyzing $name for excessive black at head or tail." + duration=`ffprobe "$1" -show_format 2> /dev/null | grep duration | cut -d= -f2 | cut -d. -f1` + tail_start=`echo "$duration - $analysis_tail_seconds" | bc` + head_black=`ffmpeg -t "$analysis_head_seconds" -i "$1" -an -vf blackdetect=pix_th=0.05 -loglevel debug -f null - 2>&1 | grep -c -o picture_black_ratio:1` + report -dt "Black frames in first $analysis_head_seconds seconds: $head_black." + tail_black=`ffmpeg -ss "$tail_start" -i "$1" -an -vf blackdetect=pix_th=0.05 -loglevel debug -f null - 2>&1 | grep -c -o picture_black_ratio:1` + report -dt "Black frames in last $analysis_head_seconds seconds: $tail_black." } maketemp(){ - tempfoo=`basename $0` - TMPFILE=`mktemp -q /tmp/${tempfoo}.XXXXXX` - if [ $? -ne 0 ]; then - echo "$0: Can't create temp file, exiting..." - exit 1 - fi + tempfoo=`basename $0` + TMPFILE=`mktemp -q /tmp/${tempfoo}.XXXXXX` + if [ $? -ne 0 ]; then + echo "$0: Can't create temp file, exiting..." + exit 1 + fi } ask_operator(){ - if [ -z "$op" ] ; then - report -qn "Enter the name of the operator or 'q' to quit: " - read op - [ -z "$op" ] && ask_operator || log+="operator: ${op}\n" - [ "$op" == "q" ] && exit 0 - fi + if [ -z "$op" ] ; then + report -qn "Enter the name of the operator or 'q' to quit: " + read op + [ -z "$op" ] && ask_operator || log+="operator: ${op}\n" + [ "$op" == "q" ] && exit 0 + fi } ask_mediaid(){ - if [ -z "$mediaid" ] ; then - report -qn "Enter a unique MEDIA ID: " - read mediaid - [ -z "$mediaid" ] && ask_mediaid - # option to quit - [ "$mediaid" == "q" ] && exit 0 - # validate id and perhaps fail with exit - [ -z "$mediaid" ] && report -wt "ERROR You must enter a valid MEDIA ID" && exit - [ ! -z `echo "$mediaid" | grep -v "^[A-Z0-9_-]*$"` ] && report -wt "ERROR The MEDIA ID must only contain capital letters, letters, hyphen and underscore" && exit 1 - fi - [ ! -z "$mediaid" ] && log+="mediaid: ${mediaid}\n" + if [ -z "$mediaid" ] ; then + report -qn "Enter a unique MEDIA ID: " + read mediaid + [ -z "$mediaid" ] && ask_mediaid + # option to quit + [ "$mediaid" == "q" ] && exit 0 + # validate id and perhaps fail with exit + [ -z "$mediaid" ] && report -wt "ERROR You must enter a valid MEDIA ID" && exit + [ ! -z `echo "$mediaid" | grep -v "^[A-Z0-9_-]*$"` ] && report -wt "ERROR The MEDIA ID must only contain capital letters, letters, hyphen and underscore" && exit 1 + fi + [ ! -z "$mediaid" ] && log+="mediaid: ${mediaid}\n" } ask_input(){ - if [ -z "$input" ] ; then - report -qn "Drag in the file: " - read input - [ -z "$input" ] && ask_input - [ "$input" == "q" ] && exit 0 - basename=`basename "$input"` - [ ! -z "$input log" ] && log+="input: ${input}\n" - fi + if [ -z "$input" ] ; then + report -qn "Drag in the file: " + read input + [ -z "$input" ] && ask_input + [ "$input" == "q" ] && exit 0 + basename=`basename "$input"` + [ ! -z "$input log" ] && log+="input: ${input}\n" + fi } check_dependencies(){ - deps_ok=YES - while [ "$*" != "" ] ; do - dependency="$1" - if [ ! $(which $dependency) ] ; then - report -wt "This script requires $dependency to run but it is not installed" - report -wt "If you are running ubuntu or debian you might be able to install $dependency with the following command" - report -wt "sudo apt-get install ${dependency}" - report -wt "If you are running mac you might be able to install $dependency with the following command" - report -wt "brew install ${dependency}" - deps_ok=NO - fi - shift - done - if [[ "$deps_ok" == "NO" ]]; then - report -wt "Unmet dependencies" - report -wt "Aborting!" - exit 1 - else - return 0 - fi + deps_ok=YES + while [ "$*" != "" ] ; do + dependency="$1" + if [ ! $(which $dependency) ] ; then + report -wt "This script requires $dependency to run but it is not installed" + report -wt "If you are running ubuntu or debian you might be able to install $dependency with the following command" + report -wt "sudo apt-get install ${dependency}" + report -wt "If you are running mac you might be able to install $dependency with the following command" + report -wt "brew install ${dependency}" + deps_ok=NO + fi + shift + done + if [[ "$deps_ok" == "NO" ]]; then + report -wt "Unmet dependencies" + report -wt "Aborting!" + exit 1 + else + return 0 + fi } ask(){ - # This function requires 3 arguments - # 1) A prompt - # 2) The label for the metadata value - read -p "${1}" response - if [ -z "$response" ] ; then - ask "$1" "$2" - else - log+="${2}: ${response}\n" - fi - echo + # This function requires 3 arguments + # 1) A prompt + # 2) The label for the metadata value + read -p "${1}" response + if [ -z "$response" ] ; then + ask "$1" "$2" + else + log+="${2}: ${response}\n" + fi + echo } offerChoice(){ - # This function requires 3 arguments - # 1) A prompt - # 2) The label for the metadata value - # 3) A vocabulary list - PS3="${1}" - label="${2}" - eval set "$3" - select option in "$@" - do - break - done - log+="${label}: ${option}\n" - echo + # This function requires 3 arguments + # 1) A prompt + # 2) The label for the metadata value + # 3) A vocabulary list + PS3="${1}" + label="${2}" + eval set "$3" + select option in "$@" + do + break + done + log+="${label}: ${option}\n" + echo } make_mezz_for_xdcam(){ - som="$1" - dur="$2" + som="$1" + dur="$2" - tmc_ms=`mediainfo --inform="Video;%Delay%" "$3"` - tmc_smp=`mediainfo --inform="Video;%Delay/String3%" "$3"` - tmc_sec=`echo "$tmc_ms * 0.001" | bc` + tmc_ms=`mediainfo --inform="Video;%Delay%" "$3"` + tmc_smp=`mediainfo --inform="Video;%Delay/String3%" "$3"` + tmc_sec=`echo "$tmc_ms * 0.001" | bc` - som_h=`echo "$som" | cut -c 1-2` - som_m=`echo "$som" | cut -c 4-5` - som_s=`echo "$som" | cut -c 7-8` - som_f=`echo "$som" | cut -c 10-11` - som_fc=`echo "scale=3; (((((3600 * $som_h)+(60 * $som_m)+ $som_s ) * 30)+ $som_f ) - ( 2 * (((60 * $som_h)+ $som_m ) - (((60 * $som_h)+ $som_m ) / 10 )))) / 29.97" | bc` + som_h=`echo "$som" | cut -c 1-2` + som_m=`echo "$som" | cut -c 4-5` + som_s=`echo "$som" | cut -c 7-8` + som_f=`echo "$som" | cut -c 10-11` + som_fc=`echo "scale=3; (((((3600 * $som_h)+(60 * $som_m)+ $som_s ) * 30)+ $som_f ) - ( 2 * (((60 * $som_h)+ $som_m ) - (((60 * $som_h)+ $som_m ) / 10 )))) / 29.97" | bc` - dur_h=`echo "$dur" | cut -c 1-2` - dur_m=`echo "$dur" | cut -c 4-5` - dur_s=`echo "$dur" | cut -c 7-8` - dur_f=`echo "$dur" | cut -c 10-11` - dur_fc=`echo "scale=3; (((((3600 * $dur_h)+(60 * $dur_m)+ $dur_s ) * 30)+ $dur_f ) - ( 2 * (((60 * $dur_h)+ $dur_m ) - (((60 * $dur_h)+ $dur_m ) / 10 )))) / 29.97" | bc` + dur_h=`echo "$dur" | cut -c 1-2` + dur_m=`echo "$dur" | cut -c 4-5` + dur_s=`echo "$dur" | cut -c 7-8` + dur_f=`echo "$dur" | cut -c 10-11` + dur_fc=`echo "scale=3; (((((3600 * $dur_h)+(60 * $dur_m)+ $dur_s ) * 30)+ $dur_f ) - ( 2 * (((60 * $dur_h)+ $dur_m ) - (((60 * $dur_h)+ $dur_m ) / 10 )))) / 29.97" | bc` - rel_start=`echo "scale=3; $som_fc - $tmc_sec" | bc` - pushd `dirname "$4"` - report -dt "Starting ffmpeg to trim mxf file at `date`. This will take a few minutes..." - ffmpeg 2 /dev/null | grep width= | cut -d = -f 2` + width=`ffprobe "$1" -show_streams -select_streams v 2> /dev/null | grep width= | cut -d = -f 2` } get_height(){ - height=`ffprobe "$1" -show_streams -select_streams v 2> /dev/null | grep height= | cut -d = -f 2` + height=`ffprobe "$1" -show_streams -select_streams v 2> /dev/null | grep height= | cut -d = -f 2` } get_dar(){ - dar=`ffprobe "$1" -show_streams -select_streams v 2> /dev/null | grep display_aspect_ratio= | cut -d = -f 2 | sed 's|:|/|g'` + dar=`ffprobe "$1" -show_streams -select_streams v 2> /dev/null | grep display_aspect_ratio= | cut -d = -f 2 | sed 's|:|/|g'` } get_codectagstring(){ - codec_tag_string=`ffprobe "$1" -show_streams -select_streams v 2> /dev/null | grep codec_tag_string= | cut -d = -f 2` + codec_tag_string=`ffprobe "$1" -show_streams -select_streams v 2> /dev/null | grep codec_tag_string= | cut -d = -f 2` } get_duration(){ - DURATION=`ffprobe "$1" -show_format 2> /dev/null | grep duration= | cut -d = -f 2` + DURATION=`ffprobe "$1" -show_format 2> /dev/null | grep duration= | cut -d = -f 2` } get_maxdvdbitrate(){ - get_duration "$1" - local DVDCAPACITY=37000000000 # in bits - local CAPDVDBITRATE=6000000 # in bits/second - MAXDVDBITRATE=`echo "(37000000000 - ( $DURATION * 224000 )) / $DURATION" | bc` - if ! [[ "$MAXDVDBITRATE" =~ ^[0-9]+$ ]] ; then - report -wt "Calculation of dvd bitrate failed. Evaluated to ${MAXDVDBITRATE}. Using 4000000 as bitrate instead." - MAXDVDBITRATE=4000000 - elif [ "$MAXDVDBITRATE" -gt "$CAPDVDBITRATE" ] ; then - MAXDVDBITRATE="$CAPDVDBITRATE" - fi + get_duration "$1" + local DVDCAPACITY=37000000000 # in bits + local CAPDVDBITRATE=6000000 # in bits/second + MAXDVDBITRATE=`echo "(37000000000 - ( $DURATION * 224000 )) / $DURATION" | bc` + if ! [[ "$MAXDVDBITRATE" =~ ^[0-9]+$ ]] ; then + report -wt "Calculation of dvd bitrate failed. Evaluated to ${MAXDVDBITRATE}. Using 4000000 as bitrate instead." + MAXDVDBITRATE=4000000 + elif [ "$MAXDVDBITRATE" -gt "$CAPDVDBITRATE" ] ; then + MAXDVDBITRATE="$CAPDVDBITRATE" + fi } has_first_two_tracks_mono(){ - [ $(ffprobe 2>/dev/null "$1" -show_streams | grep -c "codec_type=audio") -ge 2 ] && \ - [ $(ffprobe 2>/dev/null "$1" -show_streams -select_streams a:0 -of compact=p=0 | grep -o "channels=[0-9]*" | cut -d= -f2) = "1" ] && \ - [ $(ffprobe 2>/dev/null "$1" -show_streams -select_streams a:1 -of compact=p=0 | grep -o "channels=[0-9]*" | cut -d= -f2) = "1" ] && \ - MULTIMONO="Y" + [ $(ffprobe 2>/dev/null "$1" -show_streams | grep -c "codec_type=audio") -ge 2 ] && \ + [ $(ffprobe 2>/dev/null "$1" -show_streams -select_streams a:0 -of compact=p=0 | grep -o "channels=[0-9]*" | cut -d= -f2) = "1" ] && \ + [ $(ffprobe 2>/dev/null "$1" -show_streams -select_streams a:1 -of compact=p=0 | grep -o "channels=[0-9]*" | cut -d= -f2) = "1" ] && \ + MULTIMONO="Y" } get_volume_adjustment(){ - reference=-23 - input_movie="$1" - report -dt "Getting volume data for $(basename "$input_movie") ..." - volume_data=`ffprobe -v error -of compact=p=0:nk=1 -show_entries frame=metadata:tags=lavfi.r128.I -f lavfi "amovie='${input_movie}',ebur128=metadata=1"` - [ $? -ne 0 ] && { report -wt "Volume analysis for $input_movie exited with $?." ; exit ;}; - for i in $(echo "$volume_data" | xargs); do - [ "$i" != "" ] && integrated_loudness="$i" - done - VOLADJ=`echo "$reference - $integrated_loudness" | bc` - # test to see if adjustment is at least 1dB, else skip - if [ `echo "$VOLADJ < 1" |bc` -eq 1 -a `echo "$VOLADJ > -1" |bc` -eq 1 ] ; then - report -dt "Integrated loudness for $name is ${integrated_loudness}dB. Reference is ${reference}dB. No adjustment is needed for ${name}, skipping." - VOLADJ="" - else - report -dt "Integrated loudness for $name is ${integrated_loudness}dB. Reference is ${reference}dB. Will adjust by ${VOLADJ}dB." - fi + reference=-23 + input_movie="$1" + report -dt "Getting volume data for $(basename "$input_movie") ..." + volume_data=`ffprobe -v error -of compact=p=0:nk=1 -show_entries frame=metadata:tags=lavfi.r128.I -f lavfi "amovie='${input_movie}',ebur128=metadata=1"` + [ $? -ne 0 ] && { report -wt "Volume analysis for $input_movie exited with $?." ; exit ;}; + for i in $(echo "$volume_data" | xargs); do + [ "$i" != "" ] && integrated_loudness="$i" + done + VOLADJ=`echo "$reference - $integrated_loudness" | bc` + # test to see if adjustment is at least 1dB, else skip + if [ `echo "$VOLADJ < 1" |bc` -eq 1 -a `echo "$VOLADJ > -1" |bc` -eq 1 ] ; then + report -dt "Integrated loudness for $name is ${integrated_loudness}dB. Reference is ${reference}dB. No adjustment is needed for ${name}, skipping." + VOLADJ="" + else + report -dt "Integrated loudness for $name is ${integrated_loudness}dB. Reference is ${reference}dB. Will adjust by ${VOLADJ}dB." + fi } get_cropdetection(){ - input_movie="$1" - report -dt "Getting cropping data for $(basename "$input_movie") ..." - crop_data=`ffmpeg -i "${input_movie}" -an -vf cropdetect -f null - 2>&1 | grep -o "crop=[0-9:]*"` - [ $? -ne 0 ] && { report -wt "Crop detection analysis for $input_movie exited with $?." ; exit ;}; - for i in $(echo "$crop_data" | xargs); do - [ "$i" != "" ] && CROPADJ="$i" - done - report -dt "Crop detection complete. Will crop by ${CROPADJ} (width,height,from_left,from_top) before scaling." + input_movie="$1" + report -dt "Getting cropping data for $(basename "$input_movie") ..." + crop_data=`ffmpeg -i "${input_movie}" -an -vf cropdetect -f null - 2>&1 | grep -o "crop=[0-9:]*"` + [ $? -ne 0 ] && { report -wt "Crop detection analysis for $input_movie exited with $?." ; exit ;}; + for i in $(echo "$crop_data" | xargs); do + [ "$i" != "" ] && CROPADJ="$i" + done + report -dt "Crop detection complete. Will crop by ${CROPADJ} (width,height,from_left,from_top) before scaling." } free_space(){ - #this should give the free space in gigabytes - local space="$1" #This value represents the space in gigabytes required for the script to run - local outputdir="$2" - [ ! -d "$outputdir" ] && { report -wt "The output directory [$outputdir] that free-space function is seeking does not exist." ; exit 1 ;}; - [[ ! $space =~ ^-?[0-9]+$ ]] && { report -wt "Number is not an integer." ; exit 1 ;}; - freespace=`df -g "$outputdir" | awk '{ print $4; }' | tail -n 1` - if [ $freespace -lt $space ]; then - report -wts "ERROR only $freespace gb free in this directory. This script requires at least $space gigabytes" - exit 1 - fi + #this should give the free space in gigabytes + local space="$1" #This value represents the space in gigabytes required for the script to run + local outputdir="$2" + [ ! -d "$outputdir" ] && { report -wt "The output directory [$outputdir] that free-space function is seeking does not exist." ; exit 1 ;}; + [[ ! $space =~ ^-?[0-9]+$ ]] && { report -wt "Number is not an integer." ; exit 1 ;}; + freespace=`df -g "$outputdir" | awk '{ print $4; }' | tail -n 1` + if [ $freespace -lt $space ]; then + report -wts "ERROR only $freespace gb free in this directory. This script requires at least $space gigabytes" + exit 1 + fi } diff --git a/mmhelp b/mmhelp index fdd27de4..855037c3 100755 --- a/mmhelp +++ b/mmhelp @@ -6,123 +6,123 @@ echo " barcode_interpret - Arguments: one or many scanned interleaved 2/5 barcode values - Description: The script will translate the scanned barcode into human a - readable numerical value and retrieve the associated identifiers. + Arguments: one or many scanned interleaved 2/5 barcode values + Description: The script will translate the scanned barcode into human a + readable numerical value and retrieve the associated identifiers. blackatend - Arguments: one or many video files. - Example: blackatend /path/to/file1.mov /path/to/file2.mov - Description: The script will decode the first and last few seconds of the file - and report on the number of black frames at each end. + Arguments: one or many video files. + Example: blackatend /path/to/file1.mov /path/to/file2.mov + Description: The script will decode the first and last few seconds of the file + and report on the number of black frames at each end. checksumpackage - Arguments: one or many Archive Information Packages (AIP) - Example: checksumpackage /path/to/package1 /path/to/package2 - Description: The script will use md5deep to produce a checksum.md5 file for - AIPs to help facilitate file integrity checks during long - term digital storage. + Arguments: one or many Archive Information Packages (AIP) + Example: checksumpackage /path/to/package1 /path/to/package2 + Description: The script will use md5deep to produce a checksum.md5 file for + AIPs to help facilitate file integrity checks during long + term digital storage. fix_left2stereo - - Arguments: one video file with .mxf or .mov extension - Example: fix_left2stereo /path/to/file1.mxf /path/to/file1.mov - Description: The script will adjust stereo audio to the left channel. + + Arguments: one video file with .mxf or .mov extension + Example: fix_left2stereo /path/to/file1.mxf /path/to/file1.mov + Description: The script will adjust stereo audio to the left channel. fix_rewrap - - Arguments: one video file with .mxf or .mov extension - Example: fix_rewrap /path/to/file1.mxf /path/to/file1.mov - Description: The script will change the wrapper of a video file. + + Arguments: one video file with .mxf or .mov extension + Example: fix_rewrap /path/to/file1.mxf /path/to/file1.mov + Description: The script will change the wrapper of a video file. fix_volume - Arguments: one video file with .mxf or .mov extension - Example: fix_volume /path/to/file1.mxf /path/to/file1.mov - Description The script will evaluate the audio of a video file to determine - the difference and adjust as needed. + Arguments: one video file with .mxf or .mov extension + Example: fix_volume /path/to/file1.mxf /path/to/file1.mov + Description The script will evaluate the audio of a video file to determine + the difference and adjust as needed. ingestfile - Arguments: one or many audiovisual files - Example: ingestfile /path/to/file1.mov /path/to/file2.mov - Description: The script will package, transcode, and ingest an audiovisual file. This script - makes use of several functions described in the mmfunctions script. + Arguments: one or many audiovisual files + Example: ingestfile /path/to/file1.mov /path/to/file2.mov + Description: The script will package, transcode, and ingest an audiovisual file. This script + makes use of several functions described in the mmfunctions script. install - Arguments: - Example: - Description: + Arguments: + Example: + Description: makebroadcast - Arguments: one or many video files. - Example: makebroadcast /path/to/file1.mov /path/to/file2.mov - Description: The script will create a broadcast version of a video file. Version 1.2 - reverts the video file to .mov and ffmbc. + Arguments: one or many video files. + Example: makebroadcast /path/to/file1.mov /path/to/file2.mov + Description: The script will create a broadcast version of a video file. Version 1.2 + reverts the video file to .mov and ffmbc. makedvd - - Arguments: one or many video files. - Example: makedvd /path/to/file1.mov /path/to/file2.mov - Description: The script will create and label a dvd version of a video file. + + Arguments: one or many video files. + Example: makedvd /path/to/file1.mov /path/to/file2.mov + Description: The script will create and label a dvd version of a video file. makemetadata - Arguments: - Example: - Description: + Arguments: + Example: + Description: makepodcast - Arguments: one or many video files. - Example: makepodcast /path/to/file1.mov /path/to/file2.mov - Description: The script will create a video file suitable for podcast. + Arguments: one or many video files. + Example: makepodcast /path/to/file1.mov /path/to/file2.mov + Description: The script will create a video file suitable for podcast. makeyoutube - Arguments: one or many video files. - Example: makeyoutube /path/to/file1.mov /path/to/file2.mov - Description: The script will create a video file suitable for youtube upload. + Arguments: one or many video files. + Example: makeyoutube /path/to/file1.mov /path/to/file2.mov + Description: The script will create a video file suitable for youtube upload. quickcompare - Arguments: two files. - Description: The script will quickly compare two files. + Arguments: two files. + Description: The script will quickly compare two files. removeDSStore - Arguments: one or many Archive Information Packages (AIP) - Example: removeDSStore /path/to/package1 /path/to/package2 - Description: The script will remove .DS_Store files from - AIPs because they are annoying. + Arguments: one or many Archive Information Packages (AIP) + Example: removeDSStore /path/to/package1 /path/to/package2 + Description: The script will remove .DS_Store files from + AIPs because they are annoying. uploadomneon - Arguments: one or many video files. - Example: uploadomneon /path/to/file1.mov /path/to/file2.mov - Description: The script will prepare and upload a video file to the Omneon. + Arguments: one or many video files. + Example: uploadomneon /path/to/file1.mov /path/to/file2.mov + Description: The script will prepare and upload a video file to the Omneon. xdcamingest - Arguments: none. The script is only run interactively. - Description: The script will ingest an xdcam disc, make a package, and deliver select files. + Arguments: none. The script is only run interactively. + Description: The script will ingest an xdcam disc, make a package, and deliver select files. " diff --git a/mmvariables b/mmvariables index a3b695e6..bbff52c9 100755 --- a/mmvariables +++ b/mmvariables @@ -32,9 +32,9 @@ log+="PlaybackDeviceSerialNo: \n" log+="Interface: \n" # dv process info -OUTDIR_INGESTDV="$HOME" #declare directory for packages of dv files to be written to during processing -DVLOG=dvgrab_capture.log #name of the log for dvgrab process data -OPLOG=ingest_operator.log #name of the log for operator process data +OUTDIR_INGESTDV="$HOME" #declare directory for packages of dv files to be written to during processing +DVLOG=dvgrab_capture.log #name of the log for dvgrab process data +OPLOG=ingest_operator.log #name of the log for operator process data # DO NOT CHANGE BELOW THIS LINE # -------------------------------- diff --git a/paperingest b/paperingest index 6e0143ca..c644028e 100755 --- a/paperingest +++ b/paperingest @@ -4,8 +4,8 @@ scriptdir=`dirname "$0"` . "$scriptdir/mmfunctions" || { echo "Missing '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;}; cleanup(){ - log -a "Process aborted" - exit 1 + log -a "Process aborted" + exit 1 } trap cleanup SIGHUP SIGINT SIGTERM @@ -16,7 +16,7 @@ ask_operator ask_mediaid if [ -d "$outputdir_paper/$mediaid" ] ; then - report -wdt "It looks like this $mediaid was already scanned. If you want to overwrite the existing one please delete $mediaid first and then try again." + report -wdt "It looks like this $mediaid was already scanned. If you want to overwrite the existing one please delete $mediaid first and then try again." exit fi diff --git a/quickcompare b/quickcompare index a0522843..90dd8397 100755 --- a/quickcompare +++ b/quickcompare @@ -6,8 +6,8 @@ scriptdir=`dirname "$0"` . "$scriptdir/mmfunctions" || { echo "Missing '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;}; cleanup(){ - log -a "Process aborted" - exit 1 + log -a "Process aborted" + exit 1 } trap cleanup SIGHUP SIGINT SIGTERM diff --git a/removeDSStore b/removeDSStore index 0e21432f..3f8f6cf4 100755 --- a/removeDSStore +++ b/removeDSStore @@ -5,18 +5,18 @@ scriptdir=`dirname "$0"` . "$scriptdir/mmfunctions" || { echo "Missing '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;}; cleanup(){ - log -a "Process aborted" - exit 1 + log -a "Process aborted" + exit 1 } trap cleanup SIGHUP SIGINT SIGTERM log -b while [ "$*" != "" ] ; do - target=$1 - if [ -d "$target" ]; then - find "$target" -name '.DS_Store' -type f -delete - fi - shift + target=$1 + if [ -d "$target" ]; then + find "$target" -name '.DS_Store' -type f -delete + fi + shift done log -e diff --git a/uploadomneon b/uploadomneon index da676d9f..e79b9554 100755 --- a/uploadomneon +++ b/uploadomneon @@ -5,37 +5,37 @@ scriptdir=`dirname "$0"` . "$scriptdir/mmfunctions" || { echo "Missing '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;}; cleanup(){ - log -a "Process aborted" - exit 1 + log -a "Process aborted" + exit 1 } trap cleanup SIGHUP SIGINT SIGTERM log -b usage(){ - echo - echo "$(basename $0) ${version}" - echo "This script may be run interactively by running it with no arguments or may be used with the following options." - echo "Usage: $(basename $0) [ -f sourcefile ] [ -i omneon_ip ] [ -n omneon_path ] [ -t tmp_dir]" - echo " -f sourcefile" - echo " -i omneonip" - echo " -n omneonpath" - echo " -t tmpdir" - exit + echo + echo "$(basename $0) ${version}" + echo "This script may be run interactively by running it with no arguments or may be used with the following options." + echo "Usage: $(basename $0) [ -f sourcefile ] [ -i omneon_ip ] [ -n omneon_path ] [ -t tmp_dir]" + echo " -f sourcefile" + echo " -i omneonip" + echo " -n omneonpath" + echo " -t tmpdir" + exit } # command-line options to set mediaid and original variables OPTIND=1 while getopts ":hm:f:t:ip" opt; do - case "$opt" in - h) usage ;; - f) input="$OPTARG" ; once="y" ;; - i) OMNEONIP="$OPTARG" ;; - n) OMNEONPATH="$OPTARG" ;; - t) TMPDIR="$OPTARG" ;; - \?) echo "Invalid option: -$OPTARG" ; exit 1 ;; - :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; - esac + case "$opt" in + h) usage ;; + f) input="$OPTARG" ; once="y" ;; + i) OMNEONIP="$OPTARG" ;; + n) OMNEONPATH="$OPTARG" ;; + t) TMPDIR="$OPTARG" ;; + \?) echo "Invalid option: -$OPTARG" ; exit 1 ;; + :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; + esac done [ ! -d "$TMPDIR" ] && echo "The temporary directory must be set. Use [ -t /path/to/temporary/directory ]." && exit 1 @@ -62,12 +62,12 @@ if [ "$status" = "Name not found." ] ; then report "The file named $filename is not currently on the omneon, proceeding..." if echo "$sourcefile" | grep -q "/Volumes/[AB][0-9]\{5\}" ; then - report -dt "The file ${filename} is coming from an LTO tape. It will first move the file to ${TMPDIR} and then upload to the omneon." - rsync -rtv --progress "$sourcefile" "${TMPDIR}/" - uploadfile="${TMPDIR}/${filename}" - removetmp="y" + report -dt "The file ${filename} is coming from an LTO tape. It will first move the file to ${TMPDIR} and then upload to the omneon." + rsync -rtv --progress "$sourcefile" "${TMPDIR}/" + uploadfile="${TMPDIR}/${filename}" + removetmp="y" else - uploadfile="$sourcefile" + uploadfile="$sourcefile" fi report -dt "Starting to ftp $filename to the Omneon..." diff --git a/xdcamingest b/xdcamingest index c0878cd4..f544b288 100755 --- a/xdcamingest +++ b/xdcamingest @@ -5,31 +5,31 @@ scriptdir=`dirname "$0"` . "$scriptdir/mmfunctions" || { echo "Missing '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;}; cleanup(){ - log -a "Process aborted" - exit 1 + log -a "Process aborted" + exit 1 } trap cleanup SIGHUP SIGINT SIGTERM log -b usage(){ - echo - echo "$(basename $0) ${version}" - echo "This script may be run interactively by running it with no arguments or may be used with the following options." - echo "Usage: $(basename $0) [ -c ingest_xd_cam ]" - echo " -c ingestxdcam" - exit + echo + echo "$(basename $0) ${version}" + echo "This script may be run interactively by running it with no arguments or may be used with the following options." + echo "Usage: $(basename $0) [ -c ingest_xd_cam ]" + echo " -c ingestxdcam" + exit } # command-line options to set mediaid and original variables OPTIND=1 while getopts ":hm:f:p:a:w:y:x" opt; do - case "$opt" in - h) usage ;; - c) OUTDIR_INGESTXDCAM="$OPTARG" ;; - \?) report -w "Invalid option: -$OPTARG" ; exit 1 ;; - :) report -w "Option -$OPTARG requires an argument" ; exit 1 ;; - esac + case "$opt" in + h) usage ;; + c) OUTDIR_INGESTXDCAM="$OPTARG" ;; + \?) report -w "Invalid option: -$OPTARG" ; exit 1 ;; + :) report -w "Option -$OPTARG requires an argument" ; exit 1 ;; + esac done [ ! -d "$OUTDIR_INGESTXDCAM" ] && report -w "The XD Cam processing directory must be set. Use [ -p /path/to/XDCam/processing/directory ]." && exit 1 @@ -38,178 +38,178 @@ defaults write com.apple.desktopservices DSDontWriteNetworkStores true while true ; do - # check to make sure there is only 1 XDCam deck with mounted disk attached. - xdcam_count=`find /Volumes -name 'XDCAM*' -maxdepth 1 | wc -l | awk '{print $1}'` - while [ $xdcam_count -ne 1 ]; do - if [ $xdcam_count -gt 1 ]; then - report -wt "More than 1 XDCam deck appears to be mounted, please connect only one." - exit 3 - else - report -qn "${RED}No XDCam disk found. Check deck connection. Click return to continue or 'q' to quit: " - read ok - if [ "$ok" == "q" ]; then - exit 0 - fi - fi - xdcam_count=`find /Volumes -name 'XDCAM*' -maxdepth 1 | wc -l | awk '{print $1}'` - done - - #identify deck - xdcam_mount=`find /Volumes -name 'XDCAM*' -maxdepth 1` - deck1=`basename "$xdcam_mount"` - report -dt "Found the XDCAM deck: ${deck1}" - - report -qn "${GREEN}Scan the barcode1, type 1st media_id, or 'q' to quit: " - read barcode1 - if [ "$barcode1" == "q" ]; then - exit 0 - fi - report -qn "${GREEN}Scan the barcode2, type 2nd media_id, or 'q' to quit or leave blank if there is no second barcode: " - read barcode2 - if [ "$barcode2" == "q" ]; then - exit 0 - fi - - report -qn "${GREEN}Enter the name of the operator or 'q' to quit: " - read op - if [ "$op" == "q" ]; then - exit 0 - fi - - # there are two types of barcodes accepted - # a. A 58 byte barcode that contains mediaid, deviceid, starttime, and duration - # b. A mediaid-only barcode (other values will be requested). - if [ "$(echo ${#barcode1})" -eq 58 ] ; then - # process barcodes with barcode_interpret and parse results into pieces - barcode_values1=`${scriptdir}/barcodeinterpret $barcode1` - deviceid1=`echo $barcode_values1 | cut -d , -f 2` - materialid1=`echo $barcode_values1 | cut -d , -f 4` - som1=`echo $barcode_values1 | cut -d , -f 6` - duration1=`echo $barcode_values1 | cut -d , -f 8` - - if [ "$barcode2" != "" ] ; then - barcode_values2=`${scriptdir}/barcodeinterpret $barcode2` - deviceid2=`echo $barcode_values2 | cut -d , -f 2` - materialid2=`echo $barcode_values2 | cut -d , -f 4` - som2=`echo $barcode_values2 | cut -d , -f 6` - duration2=`echo $barcode_values2 | cut -d , -f 8` - fi - else - # use the barcode for mediaid and deviceid and request other values - materialid1="$barcode1" - deviceid1="$barcode1" - report -qn "BARCODE 1 - Enter start of media in HH:MM:SS:FF format or 'q' to quit: " - read som1 - if [ "$som1" == "q" ]; then - exit 0 - fi - report -qn "BARCODE 1 - Enter duration of media in HH:MM:SS:FF format or 'q' to quit: " - read duration1 - if [ "$duration1" == "q" ]; then - exit 0 - fi - if [ "$barcode2" != "" ] ; then - materialid2="$barcode2" - deviceid2="$barcode2" - report -qn "BARCODE 2 - Enter start of media in HH:MM:SS:FF format or 'q' to quit: " - read som2 - if [ "$som2" == "q" ]; then - exit 0 - fi - report -qn "BARCODE 2 - Enter duration of media in HH:MM:SS:FF format or 'q' to quit: " - read duration2 - if [ "$duration2" == "q" ]; then - exit 0 - fi - fi - fi - - # report results of barcode scanning - echo - echo ---------------------------------- - echo deviceid1 is $deviceid1 - echo materialid1 is $materialid1 - echo som1 is $som1 - echo duration1 is $duration1 - if [ "$barcode2" != "" ] ; then - echo deviceid2 is $deviceid2 - echo materialid2 is $materialid2 - echo som2 is $som2 - echo duration2 is $duration2 - fi - echo ---------------------------------- - PS3="Do you values look correct? " - eval set "'Yes' 'No'" - select option in "$@" - do - break - done - if [ "$option" != "Yes" ] ; then - echo Start Over - echo - else - # check for existing output - if [ -d "$OUTDIR_INGESTXDCAM/$deviceid1" ] ; then - report -dt "It looks like $deviceid1 was already ingested. If you want to overwrite the existing one please delete $OUTDIR_INGESTXDCAM/$deviceid1 first and then try again." - else - # start xdcam ingest process - start=`date -u "+%Y%m%dT%H%M%SZ"` - mkdir -p "$OUTDIR_INGESTXDCAM/$deviceid1/object" - report -dt "copying disc..." - rsync -rtv --stats --progress --log-file="$OUTDIR_INGESTXDCAM/$deviceid1/object/cp.log" "/Volumes/${deck1}" "$OUTDIR_INGESTXDCAM/$deviceid1/object/" - end=`date -u "+%Y%m%dT%H%M%SZ"` - hdiutil eject "/Volumes/${deck1}" - - mxffile=`find "${OUTDIR_INGESTXDCAM}/${deviceid1}/object/${deck1}/Clip" -name "*.MXF"` - if [[ `echo "$mxffile" | wc -l | sed 's/ //g'` > 1 ]] ; then - echo error. The clip directory of "$deviceid1" has more than 1 MXF file. - exit 1 - fi - - # test for data track - hasdata1=`if [ $(ffprobe -show_streams "$mxffile" 2>&1 | grep codec_type=data | wc -l) = 0 ] ; then echo no; else echo yes; fi` - - # start reporting to operator log - echo "datetime_start: ${start}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" - echo "datetime_end: ${end}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" - echo "operator: ${op}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" - echo "deck: ${deck1}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" - echo "barcode.1: ${barcode1}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" - echo "deviceid.1: ${deviceid1}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" - echo "materialid.1: ${materialid1}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" - echo "som.1: ${som1}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" - echo "duration.1: ${duration1}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" - echo "mxffile.1: ${mxffile}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" - echo "hasdata.1: ${hasdata1}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" - if [ "$barcode2" != "" ] ; then - echo "barcode.2: ${barcode2}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" - echo "deviceid.2: ${deviceid2}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" - echo "materialid.2: ${materialid2}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" - echo "som.2: ${som2}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" - echo "duration.2: ${duration2}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" - fi - - # make and deliver broadcast version - report -dt "making omneon version..." - mezzfiledir="${OUTDIR_INGESTXDCAM}/${deviceid1}/broadcast_version" - mkdir -p "$mezzfiledir" - report -dt "running make_mezz_for_xdcam $som1 $duration1 $mxffile $mezzfiledir/${materialid1}.mxf" - make_mezz_for_xdcam "$som1" "$duration1" "$mxffile" "$mezzfiledir/${materialid1}.mxf" - report -dt "starting to ftp the broadcast file for "${materialid1}" to the Omneon..." - "${scriptdir}/uploadomneon" "$mezzfiledir/${materialid1}.mxf" - - if [ "$barcode2" != "" ] ; then - report -dt "running make_mezz_for_xdcam $som2 $duration2 $mxffile $mezzfiledir/${materialid2}.mxf" - make_mezz_for_xdcam "$som2" "$duration2" "$mxffile" "$mezzfiledir/${materialid2}.mxf" - report -dt "starting to ftp the broadcast file for "${materialid2}" to the Omneon..." - "${scriptdir}/uploadomneon" "$mezzfiledir/${materialid2}.mxf" - fi - - report -dt "starting initial checksum and packaging..." - bag baginplace "${OUTDIR_INGESTXDCAM}/${deviceid1}" - - report -dt "done with $deviceid1 at `date`" - fi - fi + # check to make sure there is only 1 XDCam deck with mounted disk attached. + xdcam_count=`find /Volumes -name 'XDCAM*' -maxdepth 1 | wc -l | awk '{print $1}'` + while [ $xdcam_count -ne 1 ]; do + if [ $xdcam_count -gt 1 ]; then + report -wt "More than 1 XDCam deck appears to be mounted, please connect only one." + exit 3 + else + report -qn "${RED}No XDCam disk found. Check deck connection. Click return to continue or 'q' to quit: " + read ok + if [ "$ok" == "q" ]; then + exit 0 + fi + fi + xdcam_count=`find /Volumes -name 'XDCAM*' -maxdepth 1 | wc -l | awk '{print $1}'` + done + + #identify deck + xdcam_mount=`find /Volumes -name 'XDCAM*' -maxdepth 1` + deck1=`basename "$xdcam_mount"` + report -dt "Found the XDCAM deck: ${deck1}" + + report -qn "${GREEN}Scan the barcode1, type 1st media_id, or 'q' to quit: " + read barcode1 + if [ "$barcode1" == "q" ]; then + exit 0 + fi + report -qn "${GREEN}Scan the barcode2, type 2nd media_id, or 'q' to quit or leave blank if there is no second barcode: " + read barcode2 + if [ "$barcode2" == "q" ]; then + exit 0 + fi + + report -qn "${GREEN}Enter the name of the operator or 'q' to quit: " + read op + if [ "$op" == "q" ]; then + exit 0 + fi + + # there are two types of barcodes accepted + # a. A 58 byte barcode that contains mediaid, deviceid, starttime, and duration + # b. A mediaid-only barcode (other values will be requested). + if [ "$(echo ${#barcode1})" -eq 58 ] ; then + # process barcodes with barcode_interpret and parse results into pieces + barcode_values1=`${scriptdir}/barcodeinterpret $barcode1` + deviceid1=`echo $barcode_values1 | cut -d , -f 2` + materialid1=`echo $barcode_values1 | cut -d , -f 4` + som1=`echo $barcode_values1 | cut -d , -f 6` + duration1=`echo $barcode_values1 | cut -d , -f 8` + + if [ "$barcode2" != "" ] ; then + barcode_values2=`${scriptdir}/barcodeinterpret $barcode2` + deviceid2=`echo $barcode_values2 | cut -d , -f 2` + materialid2=`echo $barcode_values2 | cut -d , -f 4` + som2=`echo $barcode_values2 | cut -d , -f 6` + duration2=`echo $barcode_values2 | cut -d , -f 8` + fi + else + # use the barcode for mediaid and deviceid and request other values + materialid1="$barcode1" + deviceid1="$barcode1" + report -qn "BARCODE 1 - Enter start of media in HH:MM:SS:FF format or 'q' to quit: " + read som1 + if [ "$som1" == "q" ]; then + exit 0 + fi + report -qn "BARCODE 1 - Enter duration of media in HH:MM:SS:FF format or 'q' to quit: " + read duration1 + if [ "$duration1" == "q" ]; then + exit 0 + fi + if [ "$barcode2" != "" ] ; then + materialid2="$barcode2" + deviceid2="$barcode2" + report -qn "BARCODE 2 - Enter start of media in HH:MM:SS:FF format or 'q' to quit: " + read som2 + if [ "$som2" == "q" ]; then + exit 0 + fi + report -qn "BARCODE 2 - Enter duration of media in HH:MM:SS:FF format or 'q' to quit: " + read duration2 + if [ "$duration2" == "q" ]; then + exit 0 + fi + fi + fi + + # report results of barcode scanning + echo + echo ---------------------------------- + echo deviceid1 is $deviceid1 + echo materialid1 is $materialid1 + echo som1 is $som1 + echo duration1 is $duration1 + if [ "$barcode2" != "" ] ; then + echo deviceid2 is $deviceid2 + echo materialid2 is $materialid2 + echo som2 is $som2 + echo duration2 is $duration2 + fi + echo ---------------------------------- + PS3="Do you values look correct? " + eval set "'Yes' 'No'" + select option in "$@" + do + break + done + if [ "$option" != "Yes" ] ; then + echo Start Over + echo + else + # check for existing output + if [ -d "$OUTDIR_INGESTXDCAM/$deviceid1" ] ; then + report -dt "It looks like $deviceid1 was already ingested. If you want to overwrite the existing one please delete $OUTDIR_INGESTXDCAM/$deviceid1 first and then try again." + else + # start xdcam ingest process + start=`date -u "+%Y%m%dT%H%M%SZ"` + mkdir -p "$OUTDIR_INGESTXDCAM/$deviceid1/object" + report -dt "copying disc..." + rsync -rtv --stats --progress --log-file="$OUTDIR_INGESTXDCAM/$deviceid1/object/cp.log" "/Volumes/${deck1}" "$OUTDIR_INGESTXDCAM/$deviceid1/object/" + end=`date -u "+%Y%m%dT%H%M%SZ"` + hdiutil eject "/Volumes/${deck1}" + + mxffile=`find "${OUTDIR_INGESTXDCAM}/${deviceid1}/object/${deck1}/Clip" -name "*.MXF"` + if [[ `echo "$mxffile" | wc -l | sed 's/ //g'` > 1 ]] ; then + echo error. The clip directory of "$deviceid1" has more than 1 MXF file. + exit 1 + fi + + # test for data track + hasdata1=`if [ $(ffprobe -show_streams "$mxffile" 2>&1 | grep codec_type=data | wc -l) = 0 ] ; then echo no; else echo yes; fi` + + # start reporting to operator log + echo "datetime_start: ${start}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" + echo "datetime_end: ${end}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" + echo "operator: ${op}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" + echo "deck: ${deck1}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" + echo "barcode.1: ${barcode1}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" + echo "deviceid.1: ${deviceid1}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" + echo "materialid.1: ${materialid1}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" + echo "som.1: ${som1}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" + echo "duration.1: ${duration1}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" + echo "mxffile.1: ${mxffile}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" + echo "hasdata.1: ${hasdata1}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" + if [ "$barcode2" != "" ] ; then + echo "barcode.2: ${barcode2}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" + echo "deviceid.2: ${deviceid2}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" + echo "materialid.2: ${materialid2}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" + echo "som.2: ${som2}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" + echo "duration.2: ${duration2}" >> "$OUTDIR_INGESTXDCAM/$deviceid1/object/op.log" + fi + + # make and deliver broadcast version + report -dt "making omneon version..." + mezzfiledir="${OUTDIR_INGESTXDCAM}/${deviceid1}/broadcast_version" + mkdir -p "$mezzfiledir" + report -dt "running make_mezz_for_xdcam $som1 $duration1 $mxffile $mezzfiledir/${materialid1}.mxf" + make_mezz_for_xdcam "$som1" "$duration1" "$mxffile" "$mezzfiledir/${materialid1}.mxf" + report -dt "starting to ftp the broadcast file for "${materialid1}" to the Omneon..." + "${scriptdir}/uploadomneon" "$mezzfiledir/${materialid1}.mxf" + + if [ "$barcode2" != "" ] ; then + report -dt "running make_mezz_for_xdcam $som2 $duration2 $mxffile $mezzfiledir/${materialid2}.mxf" + make_mezz_for_xdcam "$som2" "$duration2" "$mxffile" "$mezzfiledir/${materialid2}.mxf" + report -dt "starting to ftp the broadcast file for "${materialid2}" to the Omneon..." + "${scriptdir}/uploadomneon" "$mezzfiledir/${materialid2}.mxf" + fi + + report -dt "starting initial checksum and packaging..." + bag baginplace "${OUTDIR_INGESTXDCAM}/${deviceid1}" + + report -dt "done with $deviceid1 at `date`" + fi + fi done log -e