From ad37593bf55305194e602e157e2015afdb7b677e Mon Sep 17 00:00:00 2001 From: dinahhandel Date: Mon, 26 Oct 2015 11:50:22 -0400 Subject: [PATCH] Standardized variables and functions across all mm scripts. --- barcodeinterpret | 80 ++-- blackatends | 32 +- checksum2filemaker | 24 +- checksumpackage | 120 +++--- finishpackage | 4 +- fix_left2stereo | 58 +-- fix_rewrap | 54 +-- fix_volume | 84 ++--- ingestfile | 351 +++++++++--------- makebroadcast | 302 +++++++-------- makedvd | 200 +++++----- makeflv | 134 +++---- makeframes | 88 ++--- makelossless | 114 +++--- makemetadata | 78 ++-- makemp3 | 102 +++--- makepdf | 126 +++---- makepodcast | 108 +++--- makeprores | 120 +++--- makeqctoolsreport | 8 +- makeyoutube | 160 ++++---- mmconfig | 86 ++--- mmfunctions | 771 ++++++++++++++++++++------------------- mmupdate | 14 +- paperingest | 76 ++-- quickcompare | 14 +- removeDSStore | 14 +- restructureForCompliance | 44 +-- uploadomneon | 110 +++--- verifypackage | 88 ++--- xdcamingest | 246 ++++++------- 31 files changed, 1906 insertions(+), 1904 deletions(-) diff --git a/barcodeinterpret b/barcodeinterpret index 6bb4be59..aa230be2 100755 --- a/barcodeinterpret +++ b/barcodeinterpret @@ -1,68 +1,68 @@ #!/bin/bash # interpret Interleaved 2/5 barcode 58 byte barcode values used by the ProBell tape management system -scriptdir=$(dirname "${0}") -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; +SCRIPTDIR=$(dirname "${0}") +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; -cleanup(){ +_cleanup(){ _log -a "Process aborted" exit 1 } -trap cleanup SIGHUP SIGINT SIGTERM +trap _cleanup SIGHUP SIGINT SIGTERM _log -b -if test $# != 1 ; then +if test "${#}" != 1 ; then echo "You must supply one argument, a scanned interleaved 2/5 barcode value"; exit fi -barcode="${1}" +BARCODE="${1}" translatebyte() { - val=$(echo $1 | echo $(cut -c $2-$3) + 32 | bc) - if [ "$val" = 131 ] ; then - echo 9 | awk '{printf("%c", $0);}' + 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);}' + echo "${VAL}" | awk '{printf("%c", ${0});}' fi } -addcolons() +_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() +_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) +IDS=$(_get_ids "${BARCODE}") -materialid=$(echo $ids | cut -d ' ' -f 2) -if [[ $(echo "$materialid" | tail -c +9 | head -c 1) == "H" ]] ; then - materialid="${materialid}D" +MATERIALID=$(echo "${IDS}" | cut -d ' ' -f 2) +if [[ $(echo "${MATERIALID}" | tail -c +9 | head -c 1) == "H" ]] ; then + MATERIALID="${MATERIALID}D" fi -echo deviceid,$(echo $ids | cut -d ' ' -f 1),materialid,$materialid,som,$(addcolons $(echo $barcode | cut -c 42-49)),duration,$(addcolons $(echo $barcode | cut -c 50-57)) +echo DEVICEID,$(echo "${IDS}" | cut -d ' ' -f 1),MATERIALID,${MATERIALID},SOM,$(_addcolons $(echo "${BARCODE}" | cut -c 42-49)),duration,$(_addcolons $(echo "${BARCODE}" | cut -c 50-57)) _log -e diff --git a/blackatends b/blackatends index ef34de18..8727cf0c 100755 --- a/blackatends +++ b/blackatends @@ -1,46 +1,46 @@ #!/bin/bash # blackatends # Accepts one or many video files as an input and determines how many frames of black are at the beginning and at the end -scriptdir=$(dirname "${0}") -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; -version=1.0 +SCRIPTDIR=$(dirname "${0}") +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; +VERSION=1.0 -cleanup(){ +_cleanup(){ _log -a "Process aborted" exit 1 } -trap cleanup SIGHUP SIGINT SIGTERM +trap _cleanup SIGHUP SIGINT SIGTERM -usage(){ +_usage(){ echo - echo "$(basename "${0}") ${version}" + echo "$(basename "${0}") ${VERSION}" echo "This program will report on the number of black frames at the beginning and end of a video file." echo - echo "Usage: $(basename $0) file1 [ file2 ... ]" + echo "Usage: $(basename ${0}) file1 [ file2 ... ]" echo echo "Options:" echo " -h display this help" echo exit } -[ "$#" = 0 ] && usage +[ "${#}" = 0 ] && _usage # command-line options to set mediaid and original variables OPTIND=1 -while getopts ":h" opt; do - case "$opt" in - h) usage ;; - \?) echo "Invalid option: -$OPTARG" ; exit 1 ;; - :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; +while getopts ":h" OPT; do + case "${OPT}" in + h) _usage ;; + \?) echo "Invalid option: -${OPTARG}" ; exit 1 ;; + :) echo "Option -${OPTARG} requires an argument" ; exit 1 ;; esac done shift $(( ${OPTIND} - 1 )) while [ "${*}" != "" ] ; do _log -b - [ "$#" != 0 ] && sourcefile="${1}" - black_at_ends "$sourcefile" + [ "${#}" != 0 ] && SOURCEFILE="${1}" + _black_at_ends "${SOURCEFILE}" _log -e shift done diff --git a/checksum2filemaker b/checksum2filemaker index f9a0e56f..746b0cbf 100755 --- a/checksum2filemaker +++ b/checksum2filemaker @@ -1,6 +1,6 @@ #!/bin/bash # This script presumes that you've setup a filemaker database with Filemaker Server using a table called 'checksums' with fields according to the DFXML format. -version=1.0 +VERSION=1.0 SCRIPTDIR=$(dirname "${0}") . "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; @@ -10,23 +10,23 @@ SCRIPTDIR=$(dirname "${0}") [ -z "${FILEMAKER_XML_URL}" ] && { echo "The filemaker xml path must be set. Run mmconfig to set FILEMAKER_XML_URL." ; exit 1 ;}; while [ "${*}" != "" ] ; do - input="${1}" - if [[ ! -f "${input}/metadata/checksum.md5" ]] ; then - report -dt "${input} does not have a checksum.md5 file, skipping for $(basename "$input")" + INPUT="${1}" + if [[ ! -f "${INPUT}/metadata/checksum.md5" ]] ; then + _report -dt "${INPUT} does not have a checksum.md5 file, skipping for $(basename "${INPUT}")" shift continue fi - OLDIFS=$IFS + OLDIFS="${IFS}" IFS=$'\n' - echo "Uploading checksum data for $(basename "$input"). Please wait…" - for hash in $(cat "${input}/metadata/checksum.md5"); do - if [[ "$hash" ]] ; then - hashinsert=$(echo "$hash" | awk '{ printf " --data-urlencode \"hashdigest=" $1 "\" --data-urlencode \"filename=" $NF "\" --data-urlencode \"hashdigest_type=MD5\"" }')" --data-urlencode \"source=$input\" --data-urlencode \"uniq="checksum.md5.${input}.${hash}.${1}"\"" - hashcmd="curl -s -S -G $hashinsert \"http://${FILEMAKER_XML_URL}?-db=${FILEMAKER_DB}&-lay=checksums&-new\" 1>/dev/null" - eval "$hashcmd" + echo "Uploading checksum data for $(basename "${INPUT}"). Please wait…" + for HASH in $(cat "${INPUT}/metadata/checksum.md5"); do + if [[ "$HASH" ]] ; then + HASHINSERT=$(echo "$HASH" | awk '{ printf " --data-urlencode \"hashdigest=" $1 "\" --data-urlencode \"FILENAME=" $NF "\" --data-urlencode \"hashdigest_type=MD5\"" }')" --data-urlencode \"source=${INPUT}\" --data-urlencode \"uniq="checksum.md5.${INPUT}.${HASH}.${1}"\"" + HASHCMD="curl -s -S -G ${HASHINSERT} \"http://${FILEMAKER_XML_URL}?-db=${FILEMAKER_DB}&-lay=checksums&-new\" 1>/dev/null" + eval "${HASHCMD}" fi done - IFS=$OLDIFS + IFS="${OLDIFS}" echo "Done uploading metadata for $(basename "${1}")." shift done diff --git a/checksumpackage b/checksumpackage index 253ad779..be256c0f 100755 --- a/checksumpackage +++ b/checksumpackage @@ -3,23 +3,23 @@ # make checksum.md5 via md5deep for package # version 1.1 adds use of dfxml # version 1.2 fixes + add options to check and verify existing checksums -version=1.2 +VERSION=1.2 -scriptdir=$(dirname "${0}") -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; -unset dependencies -dependencies=(md5deep xml "${scriptdir}/removeDSStore") +SCRIPTDIR=$(dirname "${0}") +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; +unset DEPENDENCIES +DEPENDENCIES=(md5deep xml "${SCRIPTDIR}/removeDSStore") # local variables CHECKSUMNAME="checksum.md5" DFXMLNAME="dfxml.xml" CHECKSUMPROCESSLOG="checksumchecks.log" -usage(){ +_usage(){ echo - echo "$(basename "${0}") ${version}" + echo "$(basename "${0}") ${VERSION}" echo "This application will create a checksum from a directory or package input with the following options. Actions and results will be logged to ${CHECKSUMPROCESSLOG}." - echo "Dependencies: ${dependencies[@]}" + echo "Dependencies: ${DEPENDENCIES[@]}" echo "Usage: $(basename "${0}") directoryorpackage1 [ directoryorpackage2 ...]" echo " -c ( check filenames and filesizes in objects directory are the same as in existing checksum files, if none exists it will make the initial ones )" echo " -u ( valid only if -c is used. If the check is unsuccessful then make new checksums and version the previous ones. )" @@ -28,78 +28,78 @@ usage(){ echo exit } -[ "${#}" = 0 ] && usage -check_dependencies "${dependencies[@]}" +[ "${#}" = 0 ] && _usage +_check_dependencies "${DEPENDENCIES[@]}" if [[ $(echo "$(md5deep -v) >= 4.4" | bc) = 0 ]] ; then - report -wt "$(basename "${0}") requires md5deep 4.4 or greater." + _report -wt "$(basename "${0}") requires md5deep 4.4 or greater." exit 1 fi -cleanup(){ +_cleanup(){ _log -a "Process aborted" exit 1 } # command-line options -check="" -verify="" -update="" +CHECK="" +VERIFY="" +UPDATE="" OPTIND=1 -while getopts ":cvuh" opt ; do - case "${opt}" in - c) check="Y";; - v) verify="Y";; - u) update="Y";; - h) usage ;; - *) echo "bad option -$OPTARG" ; usage ;; - :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; +while getopts ":cvuh" OPT ; do + case "${OPT}" in + c) CHECK="Y";; + v) VERIFY="Y";; + u) UPDATE="Y";; + h) _usage ;; + *) echo "bad option -${OPTARG}" ; _usage ;; + :) echo "Option -${OPTARG} requires an argument" ; exit 1 ;; esac done shift $(( ${OPTIND} - 1 )) -trap cleanup SIGHUP SIGINT SIGTERM +trap _cleanup SIGHUP SIGINT SIGTERM _check_dfxml(){ PACKAGE="${1}" # make temp file that lists filenames and filesizes from dfxml.xml - DFXML_FILELIST="$(maketemp)" + DFXML_FILELIST="$(_maketemp)" if [ ! -z "$(xml sel -T -t -m "/_:dfxml/_:fileobject" -v "_:filename" -o " " -v "_:filesize" -n "${PACKAGE}/${OUTDIR}/${DFXMLNAME}" 2>/dev/null)" ] ; then xml sel -T -t -m "/_:dfxml/_:fileobject" -v "_:filename" -o " " -v "_:filesize" -n "${PACKAGE}/${OUTDIR}/${DFXMLNAME}" | sort > "${DFXML_FILELIST}" else xml sel -T -t -m "/dfxml/fileobject" -v "filename" -o " " -v "filesize" -n "${PACKAGE}/${OUTDIR}/${DFXMLNAME}" | sort > "${DFXML_FILELIST}" fi - pwd=$(pwd) + PWD=$(pwd) # make temp file that lists filenames and filesizes from current objects directory - NEW_FILELIST="$(maketemp)" + NEW_FILELIST="$(_maketemp)" cd "${PACKAGE}/${INDIR}" find . -type f ! -name '.DS_Store' | while read i ; do echo -n "$i " ls -l "$i" | awk '{print $5}' done | sort > "${NEW_FILELIST}" - cd "${pwd}" + cd "${PWD}" # compare them if [[ $(diff "${DFXML_FILELIST}" "${NEW_FILELIST}") ]] ; then - report -wt "filepaths and sizes are different for ${1}" + _report -wt "filepaths and sizes are different for ${1}" diff "${DFXML_FILELIST}" "${NEW_FILELIST}" - echo "$(get_iso8601): $(basename "${0}"):${version}: failed to verify by filepath and size" >> "${PACKAGE}/${OUTDIR}/${CHECKSUMPROCESSLOG}" + echo "$(_get_iso8601): $(basename "${0}"):${VERSION}: failed to verify by filepath and size" >> "${PACKAGE}/${OUTDIR}/${CHECKSUMPROCESSLOG}" rm "${DFXML_FILELIST}" "${NEW_FILELIST}" - checkerr=0 + CHECKERR=0 else - report -dt "filepaths and sizes are still valid for ${1}" - echo "$(get_iso8601): $(basename "${0}"):${version}: verified by filepath and size" >> "${PACKAGE}/${OUTDIR}/${CHECKSUMPROCESSLOG}" + _report -dt "filepaths and sizes are still valid for ${1}" + echo "$(_get_iso8601): $(basename "${0}"):${VERSION}: verified by filepath and size" >> "${PACKAGE}/${OUTDIR}/${CHECKSUMPROCESSLOG}" rm "${DFXML_FILELIST}" "${NEW_FILELIST}" - checkerr=1 + CHECKERR=1 fi } _version_dfxml(){ PACKAGE="${1}" - report -wdt "Creating a new version of the checksum files." + _report -wdt "Creating a new version of the checksum files." LASTMD5="${PACKAGE}/${OUTDIR}/${CHECKSUMNAME%.*}_$(stat -t '%Y%m%d-%H%M%S' -l "${PACKAGE}/${OUTDIR}/${CHECKSUMNAME}" | awk '{print $6}').md5" LASTDFXML="${PACKAGE}/${OUTDIR}/${DFXMLNAME%.*}_$(stat -t '%Y%m%d-%H%M%S' -l "${PACKAGE}/${OUTDIR}/${DFXMLNAME}" | awk '{print $6}').xml" mv -v "${PACKAGE}/${OUTDIR}/${CHECKSUMNAME}" "${LASTMD5}" mv -v "${PACKAGE}/${OUTDIR}/${DFXMLNAME}" "${LASTDFXML}" - echo "$(get_iso8601): $(basename "${0}"):${version}: checksums are versioned - ${DFXMLNAME} -> ${LASTDFXML}" >> "${PACKAGE}/${OUTDIR}/${CHECKSUMPROCESSLOG}" - echo "$(get_iso8601): $(basename "${0}"):${version}: checksums are versioned - ${CHECKSUMNAME} -> ${LASTMD5}" >> "${PACKAGE}/${OUTDIR}/${CHECKSUMPROCESSLOG}" + echo "$(_get_iso8601): $(basename "${0}"):${VERSION}: checksums are versioned - ${DFXMLNAME} -> ${LASTDFXML}" >> "${PACKAGE}/${OUTDIR}/${CHECKSUMPROCESSLOG}" + echo "$(_get_iso8601): $(basename "${0}"):${VERSION}: checksums are versioned - ${CHECKSUMNAME} -> ${LASTMD5}" >> "${PACKAGE}/${OUTDIR}/${CHECKSUMPROCESSLOG}" } while [ "${*}" != "" ] ; do @@ -107,7 +107,7 @@ while [ "${*}" != "" ] ; do PACKAGE="${1}" if [ -d "${PACKAGE}" ] ; then PWD=$(pwd) - "${scriptdir}/removeDSStore" "${PACKAGE}" + "${SCRIPTDIR}/removeDSStore" "${PACKAGE}" if [ -d "${PACKAGE}/objects" ] ; then INDIR="objects" OUTDIR="metadata" @@ -115,14 +115,14 @@ while [ "${*}" != "" ] ; do INDIR="." OUTDIR="." fi - if [ "${check}" = "Y" ] ; then + if [ "${CHECK}" = "Y" ] ; then if [ -s "${PACKAGE}/${OUTDIR}/${DFXMLNAME}" ] ; then _check_dfxml "${PACKAGE}" - if [ "${checkerr}" != "0" ] ; then + if [ "${CHECKERR}" != "0" ] ; then shift continue else - if [ "${update}" = "Y" ] ; then + if [ "${UPDATE}" = "Y" ] ; then _version_dfxml "${PACKAGE}" else shift @@ -130,32 +130,32 @@ while [ "${*}" != "" ] ; do fi fi else - report -dt "There is no dfxml.xml to check in ${PACKAGE}, skipping." + _report -dt "There is no dfxml.xml to check in ${PACKAGE}, skipping." shift continue fi - elif [ "${verify}" = "Y" ] ; then + elif [ "${VERIFY}" = "Y" ] ; then if [ -s "${PACKAGE}/${OUTDIR}/${CHECKSUMNAME}" ] ; then - report -dt "Prepping for dfxml.xml verification." + _report -dt "Prepping for dfxml.xml verification." else - report -dt "There is no dfxml.xml to verify in ${PACKAGE}, skipping." + _report -dt "There is no dfxml.xml to verify in ${PACKAGE}, skipping." shift continue fi else if [ -s "${PACKAGE}/${OUTDIR}/${CHECKSUMNAME}" ] ; then - report -dt "${CHECKSUMNAME} already exists, skipping for ${PACKAGE}" + _report -dt "${CHECKSUMNAME} already exists, skipping for ${PACKAGE}" shift continue fi fi - report -dt "making Digital Forensics XML (${DFXMLNAME}) and (${CHECKSUMNAME}) for ${PACKAGE}" + _report -dt "making Digital Forensics XML (${DFXMLNAME}) and (${CHECKSUMNAME}) for ${PACKAGE}" cd "${PACKAGE}/${INDIR}" - DFXMLTMP=$(maketemp) - md5deep -drl . > $DFXMLTMP + DFXMLTMP=$(_maketemp) + md5deep -drl . > "${DFXMLTMP}" cd "${PWD}" [ ! -d "${PACKAGE}/${OUTDIR}" ] && mkdir -p "${PACKAGE}/${OUTDIR}" - echo "$(get_iso8601): $(basename "${0}"):${version}: ${DFXMLNAME} is generated" >> "${PACKAGE}/${OUTDIR}/${CHECKSUMPROCESSLOG}" + echo "$(_get_iso8601): $(basename "${0}"):${VERSION}: ${DFXMLNAME} is generated" >> "${PACKAGE}/${OUTDIR}/${CHECKSUMPROCESSLOG}" _version_dfxml "${PACKAGE}" cat "${DFXMLTMP}" > "${PACKAGE}/${OUTDIR}/${DFXMLNAME}" if [ ! -z "$(xml sel -T -t -m "/_:dfxml/_:fileobject" -v "_:filename" -o " " -v "_:filesize" -n "${PACKAGE}/${OUTDIR}/${DFXMLNAME}" 2>/dev/null)" ] ; then @@ -163,27 +163,27 @@ while [ "${*}" != "" ] ; do else xml sel -T -t -m "/dfxml/fileobject" -v "hashdigest" -o " " -v "filename" -n "${PACKAGE}/${OUTDIR}/${DFXMLNAME}" > "${PACKAGE}/${OUTDIR}/${CHECKSUMNAME}" fi - echo "$(get_iso8601): $(basename "${0}"):${version}: ${CHECKSUMNAME} is generated" >> "${PACKAGE}/${OUTDIR}/${CHECKSUMPROCESSLOG}" - if [ "${verify}" = "Y" ] ; then - CHECKSUMCMP1=$(maketemp) + echo "$(_get_iso8601): $(basename "${0}"):${VERSION}: ${CHECKSUMNAME} is generated" >> "${PACKAGE}/${OUTDIR}/${CHECKSUMPROCESSLOG}" + if [ "${VERIFY}" = "Y" ] ; then + CHECKSUMCMP1=$(_maketemp) sort -k2 "${PACKAGE}/${OUTDIR}/${CHECKSUMNAME}" > "${CHECKSUMCMP1}" - CHECKSUMCMP2=$(maketemp) + CHECKSUMCMP2=$(_maketemp) sort -k2 "${LASTMD5}" > "${CHECKSUMCMP2}" if [[ $(diff "${CHECKSUMCMP1}" "${CHECKSUMCMP2}") ]] ; then - report -wt "checksums are different for ${PACKAGE}" + _report -wt "checksums are different for ${PACKAGE}" diff "${CHECKSUMCMP1}" "${CHECKSUMCMP2}" - echo "$(get_iso8601): $(basename "${0}"):${version}: FAILED to VERIFY by checksums - compare ${CHECKSUMNAME} and $(basename "${LASTMD5}")" >> "${PACKAGE}/${OUTDIR}/${CHECKSUMPROCESSLOG}" + echo "$(_get_iso8601): $(basename "${0}"):${VERSION}: FAILED to VERIFY by checksums - compare ${CHECKSUMNAME} and $(basename "${LASTMD5}")" >> "${PACKAGE}/${OUTDIR}/${CHECKSUMPROCESSLOG}" else - report -dt "checksums are still valid for ${PACKAGE}" - echo "$(get_iso8601): $(basename "${0}"):${version}: verified by checksums" >> "${PACKAGE}/${OUTDIR}/${CHECKSUMPROCESSLOG}" + _report -dt "checksums are still valid for ${PACKAGE}" + echo "$(_get_iso8601): $(basename "${0}"):${VERSION}: verified by checksums" >> "${PACKAGE}/${OUTDIR}/${CHECKSUMPROCESSLOG}" fi rm "${CHECKSUMCMP1}" "${CHECKSUMCMP2}" fi #if [ "$FILEMAKER_XML_URL" ] ; then - #"${scriptdir}/checksum2filemaker" "${PACKAGE}" + #"${SCRIPTDIR}/checksum2filemaker" "${PACKAGE}" #fi else - report -dt "ERROR: ${0} requires directories as input and ${PACKAGE} is not a directory." + _report -dt "ERROR: ${0} requires directories as input and ${PACKAGE} is not a directory." fi _log -e shift diff --git a/finishpackage b/finishpackage index 371baba0..72533c19 100755 --- a/finishpackage +++ b/finishpackage @@ -1,6 +1,6 @@ #!/bin/bash while [ "${*}" != "" ] ; do - input="${1}" - makelossless "${input}" && makebroadcast "${input}" && makeyoutube "${input}" && makemetadata "${input}" && checksumpackage "${input}" + INPUT="${1}" + makelossless "${INPUT}" && makebroadcast "${INPUT}" && makeyoutube "${INPUT}" && makemetadata "${INPUT}" && checksumpackage "${INPUT}" shift done diff --git a/fix_left2stereo b/fix_left2stereo index 5ec569e9..a2984864 100755 --- a/fix_left2stereo +++ b/fix_left2stereo @@ -1,58 +1,58 @@ #!/bin/bash # left 2 stereo mix -version=1.1 -unset dependencies -dependencies=(ffmpeg ffprobe) +VERSION=1.1 +unset DEPENDENCIES +DEPENDENCIES=(ffmpeg ffprobe) -scriptdir=$(dirname "${0}") -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; +SCRIPTDIR=$(dirname "${0}") +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; -usage(){ +_usage(){ echo - echo "$(basename "${0}") ${version}" + echo "$(basename "${0}") ${VERSION}" echo "This application takes an input video file(s) and produces outputs that are map the left channel of the input to a stereo mix in the output." - echo "Dependencies: ${dependencies[@]}" + echo "Dependencies: ${DEPENDENCIES[@]}" echo "Usage: $(basename "${0}") file1 [ file2 ...]" echo exit } -[ "${#}" = 0 ] && usage -check_dependencies "${dependencies[@]}" +[ "${#}" = 0 ] && _usage +_check_dependencies "${DEPENDENCIES[@]}" -cleanup(){ +_cleanup(){ _log -a "Process aborted" exit 1 } # local variables -suffix="_left2stereo" +SUFFIX="_left2stereo" -trap cleanup SIGHUP SIGINT SIGTERM +trap _cleanup SIGHUP SIGINT SIGTERM _log -b while [ "${*}" != "" ] ; do - sourcefile="${1}" - name=$(basename "${1}") + SOURCEFILE="${1}" + NAME=$(basename "${1}") - get_codectagstring - unset ffmpeg_opts - ffmpeg_opts+=(-c:v copy -c:a pcm_s24be -ar 48000 -ac 2) - get_audio_index "${sourcefile}" - ffmpeg_opts+=(-map_channel 0.${audio_index_1}.0) - if [ "${codec_tag_string}" = "mpeg" ] ; then - extension="mxf" + _get_codectagstring + unset FFMPEG_OPTS + FFMPEG_OPTS+=(-c:v copy -c:a pcm_s24be -ar 48000 -ac 2) + _get_audio_index "${SOURCEFILE}" + FFMPEG_OPTS+=(-map_channel 0.${AUDIO_INDEX_1}.0) + if [ "${CODEC_TAG_STRING}" = "mpeg" ] ; then + EXTENSION="mxf" else - extension="mov" + EXTENSION="mov" fi - output_movie="${sourcefile%.*}${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." + OUTPUT_MOVIE="${SOURCEFILE%.*}${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 - report -dt "Generating ${output_movie} ... with these options ${ffmpeg_opts[*]}" - ffmpeg -i "${sourcefile}" "${ffmpeg_opts[@]}" "${output_movie}" - report -dt "$(basename "${0}") is done with ${name}." + _report -dt "Generating ${OUTPUT_MOVIE} ... with these options ${FFMPEG_OPTS[*]}" + ffmpeg -i "${SOURCEFILE}" "${FFMPEG_OPTS[@]}" "${OUTPUT_MOVIE}" + _report -dt "$(basename "${0}") is done with ${NAME}." fi shift done diff --git a/fix_rewrap b/fix_rewrap index 06b522d1..5f310706 100755 --- a/fix_rewrap +++ b/fix_rewrap @@ -1,57 +1,57 @@ #!/bin/bash # this script takes one argument which is a video file. It then rewraps it to make a new file. # version 1.2 swap from ffmbc to ffmpeg -version=1.2 -unset dependencies -dependencies=(ffmpeg ffprobe) +VERSION=1.2 +unset DEPENDENCIES +DEPENDENCIES=(ffmpeg ffprobe) -scriptdir=$(dirname "${0}") -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; +SCRIPTDIR=$(dirname "${0}") +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; -usage(){ +_usage(){ echo - echo "$(basename "${0}") ${version}" + echo "$(basename "${0}") ${VERSION}" echo "This application takes an input video file(s) and produces outputs through re-multiplexing all tracks of the input into a new container." - echo "Dependencies: ${dependencies[@]}" + echo "Dependencies: ${DEPENDENCIES[@]}" echo "Usage: $(basename "${0}") file1 [ file2 ...]" echo exit } -[ "${#}" = 0 ] && usage -check_dependencies "${dependencies[@]}" +[ "${#}" = 0 ] && _usage +_check_dependencies "${DEPENDENCIES[@]}" -cleanup(){ +_cleanup(){ _log -a "Process aborted" exit 1 } # local variables -suffix="_rewrap" +SUFFIX="_rewrap" -trap cleanup SIGHUP SIGINT SIGTERM +trap _cleanup SIGHUP SIGINT SIGTERM _log -b while [ "${*}" != "" ] ; do - sourcefile="${1}" - name=$(basename "${sourcefile}") + SOURCEFILE="${1}" + NAME=$(basename "${SOURCEFILE}") - get_codectagstring - unset ffmpeg_opts - ffmpeg_opts+=(-map 0:v -map 0:a -c:v copy -c:a copy) - if [ "${codec_tag_string}" = "mpeg" ] ; then - extension="mxf" + _get_codectagstring + unset FFMPEG_OPTS + FFMPEG_OPTS+=(-map 0:v -map 0:a -c:v copy -c:a copy) + if [ "${CODEC_TAG_STRING}" = "mpeg" ] ; then + EXTENSION="mxf" else - extension="mov" + EXTENSION="mov" fi - output_movie="${sourcefile%.*}${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." + OUTPUT_MOVIE="${SOURCEFILE%.*}${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 - report -dt "Generating ${output_movie} ... with these options ${ffmpeg_opts[*]}" - ffmpeg -i "${sourcefile}" "${ffmepg_opts[@]}" "${output_movie}" - report -dt "$(basename "${0}") is done with ${name}." + _report -dt "Generating ${OUTPUT_MOVIE} ... with these options ${FFMPEG_OPTS[*]}" + ffmpeg -i "${SOURCEFILE}" "${FFMPEG_OPTS[@]}" "${OUTPUT_MOVIE}" + _report -dt "$(basename "${0}") is done with ${NAME}." fi shift done diff --git a/fix_volume b/fix_volume index 654920f1..6b4e5db7 100755 --- a/fix_volume +++ b/fix_volume @@ -1,82 +1,82 @@ #!/bin/bash # this script takes one argument which is a video file. It evaluates the audio of the file, determines the difference needed to change the audio to -30dB as a mean_volume and then makes that adjustment to an output MXF file. The video track is simply copied. # version 1.1 swap from ffmbc to ffmpeg -version=1.1 -unset dependencies -dependencies=(ffmpeg ffprobe) +VERSION=1.1 +unset DEPENDENCIES +DEPENDENCIES=(ffmpeg ffprobe) # local variables -suffix="_voladj" +SUFFIX="_voladj" -scriptdir=$(dirname "${0}") -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; +SCRIPTDIR=$(dirname "${0}") +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; -usage(){ +_usage(){ echo - echo "$(basename "${0}") ${version}" - echo "This application will use an input video file to produce an output video file where the audio is adjusted to meet an integrated loudness of -23dB. If the integrated loudness of the input is already within 1dB of the target then no change will occur. The output file will be produced in the same directory as the input but be distinguished by a suffix in the filename: ${suffix}." - echo "Dependencies: ${dependencies[@]}" + echo "$(basename "${0}") ${VERSION}" + echo "This application will use an input video file to produce an output video file where the audio is adjusted to meet an integrated loudness of -23dB. If the integrated loudness of the input is already within 1dB of the target then no change will occur. The output file will be produced in the same directory as the input but be distinguished by a SUFFIX in the filename: ${SUFFIX}." + echo "Dependencies: ${DEPENDENCIES[@]}" echo "Usage: $(basename "${0}") file1 [ file2 ...]" echo " -h display this help" echo exit } -[ "${#}" = 0 ] && usage -check_dependencies "${dependencies[@]}" +[ "${#}" = 0 ] && _usage +_check_dependencies "${DEPENDENCIES[@]}" # command line arguments OPTIND=1 -while getopts ":h" opt ; do - case ${opt} in - h) usage ;; +while getopts ":h" OPT ; do + case "${OPT}" in + h) _usage ;; *) echo "Invalid option: -${OPTARG}" ; exit 1 ;; :) echo "Option -${OPTARG} requires an argument" ; exit 1 ;; esac done shift $(( ${OPTIND} - 1 )) -cleanup(){ +_cleanup(){ _log -a "Process aborted" exit 1 } -trap cleanup SIGHUP SIGINT SIGTERM +trap _cleanup SIGHUP SIGINT SIGTERM _log -b while [ "${*}" != "" ] ; do - sourcefile="${1}" - name=$(basename "${sourcefile}") - extension="${name#*.}" + SOURCEFILE="${1}" + NAME=$(basename "${SOURCEFILE}") + EXTENSION="${NAME#*.}" - get_codectagstring - unset middleoptions - middleoptions+=(-map 0:v) - middleoptions+=(-c:v copy) - middleoptions+=(-map 0:a) - middleoptions+=(-c:a pcm_s24be) - middleoptions+=(-ar 48000) - middleoptions+=(-ac 2) + _get_codectagstring + unset MIDDLEOPTIONS + MIDDLEOPTIONS+=(-map 0:v) + MIDDLEOPTIONS+=(-c:v copy) + MIDDLEOPTIONS+=(-map 0:a) + MIDDLEOPTIONS+=(-c:a pcm_s24be) + MIDDLEOPTIONS+=(-ar 48000) + MIDDLEOPTIONS+=(-ac 2) - if [ "${codec_tag_string}" = "mpeg" ] ; then - extension="mxf" + if [ "${CODEC_TAG_STRING}" = "mpeg" ] ; then + EXTENSION="mxf" else - extension="mov" + EXTENSION="mov" fi - output_movie="${sourcefile%.*}${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." + OUTPUT_MOVIE="${SOURCEFILE%.*}${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 "${sourcefile}" + _get_volume_adjustment "${SOURCEFILE}" if [ "${VOLADJ}" ] ; then - if [ $(echo "$VOLADJ < 2" |bc) -eq 1 -a $(echo "$VOLADJ > -2" |bc) -eq 1 ] ; then - report -dt "Integrated loudness for $(basename "${input_movie}") is ${integrated_loudness}dB. Reference is ${reference}dB. No adjustment is needed, skipping." + if [ $(echo "${VOLADJ} < 2" |bc) -eq 1 -a $(echo "${VOLADJ} > -2" |bc) -eq 1 ] ; then + _report -dt "Integrated loudness for $(basename "${INPUT_MOVIE}") is ${INTEGRATED_LOUDNESS}dB. Reference is ${REFERENCE}dB. No adjustment is needed, skipping." else - report -dt "Integrated loudness for $(basename "${input_movie}") is ${integrated_loudness}dB. Reference is ${reference}dB. Will adjust by ${VOLADJ}dB." - middleoptions+=(-af volume=${VOLADJ}dB) - report -dt "Generating ${output_movie} ... using these options: ${middleoptions[*]}" - ffmpeg -report -i "${sourcefile}" "${middleoptions[@]}" "${output_movie}" - report -dst "Done with ${name}." + _report -dt "Integrated loudness for $(basename "${INPUT_MOVIE}") is ${INTEGRATED_LOUDNESS}dB. Reference is ${REFERENCE}dB. Will adjust by ${VOLADJ}dB." + MIDDLEOPTIONS+=(-af volume=${VOLADJ}dB) + _report -dt "Generating ${OUTPUT_MOVIE} ... using these options: ${MIDDLEOPTIONS[*]}" + ffmpeg -report -i "${SOURCEFILE}" "${MIDDLEOPTIONS[@]}" "${OUTPUT_MOVIE}" + _report -dst "Done with ${NAME}." fi fi fi diff --git a/ingestfile b/ingestfile index 35d4b8aa..717c4612 100755 --- a/ingestfile +++ b/ingestfile @@ -1,69 +1,69 @@ #!/bin/bash # ingestfile # select an audiovisual file, package it, and transcode it -version="1.0" -requireconfig="Y" -dochecksums="Y" -formula="" -intime="" -outtime="" -cleanup="N" -makeaccesscopies="Y" # use 'Y' for yes or any other character for no -blackframetest="Y" # use 'Y' for yes or any other character for no -deliverytoomneon="Y" # use 'Y' for yes or any other character for no -deliveraccesscopies="Y" # use 'Y' for yes or any other character for no -deliverytoaipstorage="Y" # use 'Y' for yes or any other character for no - -queuefile="${HOME}/Desktop/queue.txt" -scriptdir=$(dirname "${0}") -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; +VERSION="1.0" +REQUIRECONFIG="Y" +DOCHECKSUMS="Y" +FORMULA="" +INTIME="" +OUTTIME="" +CLEANUP_CHOICE="N" +MAKEACCESSCOPIES="Y" # use 'Y' for yes or any other character for no +BLACKFRAMETEST="Y" # use 'Y' for yes or any other character for no +DELIVERYTOOMNEON="Y" # use 'Y' for yes or any other character for no +DELIVERACCESSCOPIES="Y" # use 'Y' for yes or any other character for no +DELIVERYTOAIPSTORAGE="Y" # use 'Y' for yes or any other character for no + +QUEUEFILE="${HOME}/Desktop/queue.txt" +SCRIPTDIR=$(dirname "${0}") +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; _usage(){ echo - echo "$(basename "${0}") ${version}" + echo "$(basename "${0}") ${VERSION}" echo "This script will run an interactive interview and then process an input file accordingly." - echo "Dependencies: ${dependencies[@]}" - echo "Usage: $(basename $0) [ -options ]" + echo "Dependencies: ${DEPENDENCIES[@]}" + echo "Usage: $(basename ${0}) [ -options ]" echo " -n (do not make any deliveries except for sending the final package to ${AIP_STORAGE}.)" - echo " -i (do not make any deliveries except for sending the final package to ${deliverytoomneon}.)" + echo " -i (do not make any deliveries except for sending the final package to ${DELIVERYTOOMNEON}.)" echo " -h display this help" echo exit } OPTIND=1 -while getopts ":F:pnhei" opt ; do - case "${opt}" in - F) formula="${OPTARG}";; - e) edit_mode="Y" ;; - p) preservation_mode="Y" ; deliverytoomneon="N" ; deliveraccesscopies="Y" ; deliverytoaipstorage="N" ;; - n) deliverytoomneon="N" ; deliveraccesscopies="N" ;; - i) deliverytoomneon="Y" ; deliveraccesscopies="N" ; deliverytoaipstorage="Y" ;; +while getopts ":F:pnhei" OPT ; do + case "${OPT}" in + F) FORMULA="${OPTARG}";; + e) EDIT_MODE="Y" ;; + p) PRESERVATION_MODE="Y" ; DELIVERYTOOMNEON="N" ; DELIVERACCESSCOPIES="Y" ; DELIVERYTOAIPSTORAGE="N" ;; + n) DELIVERYTOOMNEON="N" ; DELIVERACCESSCOPIES="N" ;; + i) DELIVERYTOOMNEON="Y" ; DELIVERACCESSCOPIES="N" ; DELIVERYTOAIPSTORAGE="Y" ;; h) _usage ;; - *) echo "bad option -$OPTARG" ; _usage ;; - :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; + *) echo "bad option -${OPTARG}" ; _usage ;; + :) echo "Option -${OPTARG} requires an argument" ; exit 1 ;; esac done shift $(( ${OPTIND} - 1 )) _add_mediaid_to_queue(){ - [ -n "${mediaid}" ] || { report -wt "Error: mediaid is undefined in add_media_to_queue function" ; exit 1 ;}; - [ -n "${queuefile}" ] || { report -wt "Error: queuefile is undefined in add_media_to_queue function" ; exit 1 ;}; - echo "${mediaid}" >> "${queuefile}" + [ -n "${MEDIAID}" ] || { _report -wt "Error: mediaid is undefined in add_media_to_queue function" ; exit 1 ;}; + [ -n "${QUEUEFILE}" ] || { _report -wt "Error: queuefile is undefined in add_media_to_queue function" ; exit 1 ;}; + echo "${MEDIAID}" >> "${QUEUEFILE}" } _remove_mediaid_from_queue(){ - [ -n "${mediaid}" ] || { report -wt "Error: mediaid is undefined in remove_media_from_queue function" ; exit 1 ;}; - [ -f "${queuefile}" ] || { report -wt "Error: queuefile is undefined in remove_media_from_queue function" ; exit 1 ;}; - grep -v "^${mediaid}$" "${queuefile}" | grep "^[A-Z0-9_-]\+$" > "${queuefile}_tmp" - rm "${queuefile}" - mv "${queuefile}_tmp" "${queuefile}" + [ -n "${MEDIAID}" ] || { _report -wt "Error: mediaid is undefined in remove_media_from_queue function" ; exit 1 ;}; + [ -f "${QUEUEFILE}" ] || { _report -wt "Error: queuefile is undefined in remove_media_from_queue function" ; exit 1 ;}; + grep -v "^${MEDIAID}$" "${QUEUEFILE}" | grep "^[A-Z0-9_-]\+$" > "${QUEUEFILE}_tmp" + rm "${QUEUEFILE}" + mv "${QUEUEFILE}_tmp" "${QUEUEFILE}" } _cleanup(){ _log -a "Process aborted" _remove_mediaid_from_queue - [ -d "${OUTDIR_INGESTFILE}/${mediaid}" ] && mv "${OUTDIR_INGESTFILE}/${mediaid}" "${OUTDIR_INGESTFILE}/${mediaid}_aborted_ingest_$(get_iso8601_c)" + [ -d "${OUTDIR_INGESTFILE}/${MEDIAID}" ] && mv "${OUTDIR_INGESTFILE}/${MEDIAID}" "${OUTDIR_INGESTFILE}/${MEDIAID}_aborted_ingest_$(_get_iso8601_c)" exit 1 } @@ -175,257 +175,258 @@ cb.type=cancelbutton "; # edit mode -if [ "${edit_mode}" == "Y" ] ; then - pashua_configfile=`/usr/bin/mktemp /tmp/pashua_XXXXXXXXX` - echo "$conf" > $pashua_configfile - pashua_run - rm $pashua_configfile - echo " operator = ${op}" - echo " input = ${input}" - echo " mediaid = ${mediaid}" - echo " audiodecision = ${audiodecision}" - echo " cropdetection = ${cropdetection}" - echo " formula = ${formula}" - echo " cleanupdecision = ${cleanupdecision}" - echo " priority = ${priority}" +if [ "${EDIT_MODE}" == "Y" ] ; then + PASHUA_CONFIGFILE=`/usr/bin/mktemp /tmp/pashua_XXXXXXXXX` + echo "${conf}" > "${PASHUA_CONFIGFILE}" + _pashua_run + rm "${PASHUA_CONFIGFILE}" + echo " operator = ${OP}" + echo " input = ${INPUT}" + echo " mediaid = ${MEDIAID}" + echo " audiodecision = ${AUDIODECISION}" + echo " cropdetection = ${CROPDETECTION}" + echo " formula = ${FORMULA}" + echo " cleanupdecision = ${CLEANUPDECISION}" + echo " priority = ${PRIORITY}" echo "" fi # interview the operator -ask_operator -ask_mediaid +_ask_operator +_ask_mediaid ## check for existing output -[ -d "${OUTDIR_INGESTFILE}/${mediaid}" ] && { report -wt "It looks like ${mediaid} was already ingested. If you want to overwrite the existing one please delete $OUTDIR_INGESTFILE/$mediaid first and then try again." ; exit 1 ;}; -[ -d "${AIP_STORAGE}/${mediaid}" ] && { report -wt "It looks like ${mediaid} was already ingested. If you want to overwrite the existing one please delete $AIP_STORAGE/$mediaid first and then try again." ; exit 1 ;}; -ask_input -if [ ! $(is_video "${input}") ] ; then - report -qnt "WARNING: ${input} is not recognized as a video file. Please press q to quit, any other key to continue (if you know what you're doing): " - read notvidresponse - [ "${notvidresponse}" == "q" ] && exit 0 +[ -d "${OUTDIR_INGESTFILE}/${MEDIAID}" ] && { _report -wt "It looks like ${MEDIAID} was already ingested. If you want to overwrite the existing one please delete ${OUTDIR_INGESTFILE}/${MEDIAID} first and then try again." ; exit 1 ;}; +[ -d "${AIP_STORAGE}/${MEDIAID}" ] && { _report -wt "It looks like ${MEDIAID} was already ingested. If you want to overwrite the existing one please delete ${AIP_STORAGE}/${MEDIAID} first and then try again." ; exit 1 ;}; +_ask_input +#here is where we would insert an option for searching for directory. +if [ ! $(_is_video "${INPUT}") ] ; then + _report -qnt "WARNING: ${INPUT} is not recognized as a video file. Please press q to quit, any other key to continue (if you know what you're doing): " + read NOTVIDRESPONSE + [ "${NOTVIDRESPONSE}" == "q" ] && exit 0 fi -if [ "${audiodecision}" = "" ] ; then - report -q "Select an audio strategy? " +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]" "Only use right of the first audio track" + select AUDIODECISION in "Default audio mapping [first audio track used for stereo output]" "Only use left of the first audio track [for 21st Century]" "Only use right of the first audio track" do break done fi -if [ "${cropdetection}" = "" ] ; then - report -q "Select a cropping strategy? " +if [ "${CROPDETECTION}" = "" ] ; then + _report -q "Select a cropping strategy? " PS3="Selection? " - select cropdecision in "Do not crop." "Examine the video and auto-crop out black borders (slower)" + select CROPDECISION in "Do not crop." "Examine the video and auto-crop out black borders (slower)" do break done fi -if [ "${formula}" = "" ] ; then - report -q "Select an optional formula for unusual cases? " - report -d "In most cases, select 'none'. To force the input file to be interpreted as top or bottom field first interlacement, select tff or bff. To stretch the input video to 1920x1080 HD frame size, select 'hds'." +if [ "${FORMULA}" = "" ] ; then + _report -q "Select an optional formula for unusual cases? " + _report -d "In most cases, select 'none'. To force the input file to be interpreted as top or bottom field first interlacement, select tff or bff. To stretch the input video to 1920x1080 HD frame size, select 'hds'." PS3="Selection? " - select formula in "none" "tff" "bff" "hds" + select FORMULA in "none" "tff" "bff" "hds" do break done fi -if [ "${cleanupdecision}" = "" ] ; then - report -q "Select an cleanup strategy? " +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" + 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" + if [ "${CLEANUPDECISION}" = "Remove source file after successful ingest" ] ; then + CLEANUP_CHOICE="Y" else - cleanup="N" + CLEANUP_CHOICE="N" fi fi -if [ "${priority}" = "" ] ; then - report -q "Select an multitasking strategy? " +if [ "${PRIORITY}" = "" ] ; then + _report -q "Select an multitasking strategy? " PS3="Selection? " - select priority in "put in queue" "start now" + select PRIORITY in "put in queue" "start now" do break done fi # blackframe analysis or in/out requests -if [ "${preservation_mode}" == "Y" ] ; then +if [ "${PRESERVATION_MODE}" == "Y" ] ; then _ask_intime _ask_outtime - ask_trimmed_materials + _ask_trimmed_materials else - 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 + 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 _ask_intime 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 + 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 _ask_outtime fi fi fi # queue handling -if [ "${priority}" = "put in queue" ] ; then +if [ "${PRIORITY}" = "put in queue" ] ; then _add_mediaid_to_queue - next=$(head -n 1 "${queuefile}") - while [ "${mediaid}" != "${next}" ] ; do - newnext=$(head -n 1 "${queuefile}") + NEXT=$(head -n 1 "${QUEUEFILE}") + while [ "${MEDIAID}" != "${NEXT}" ] ; do + NEWNEXT=$(head -n 1 "${QUEUEFILE}") echo -n "This process is waiting behind these identifiers: " - cat "${queuefile}" | tr '\n' ' ' + cat "${QUEUEFILE}" | tr '\n' ' ' echo - while [ "${next}" = "${newnext}" ] ; do + while [ "${NEXT}" = "${NEWNEXT}" ] ; do sleep 10 - newnext=$(head -n 1 "${queuefile}") + NEWNEXT=$(head -n 1 "${QUEUEFILE}") done - next="${newnext}" + NEXT="${NEWNEXT}" done fi _log -b # set up package directories -objectsdir="${OUTDIR_INGESTFILE}/${mediaid}/objects" -_run_critical _mkdir2 "${objectsdir}" +OBJECTSDIR="${OUTDIR_INGESTFILE}/${MEDIAID}/objects" +_run_critical _mkdir2 "${OBJECTSDIR}" -submissiondocdir="${OUTDIR_INGESTFILE}/${mediaid}/metadata/submissionDocumentation" -_run _mkdir2 "${submissiondocdir}" +SUBMISSIONDOCDIR="${OUTDIR_INGESTFILE}/${MEDIAID}/metadata/submissionDocumentation" +_run _mkdir2 "${SUBMISSIONDOCDIR}" -logdir="${OUTDIR_INGESTFILE}/${mediaid}/metadata/submissionDocumentation/logs" -_run _mkdir2 "${logdir}" +LOGDIR="${OUTDIR_INGESTFILE}/${MEDIAID}/metadata/submissionDocumentation/logs" +_run _mkdir2 "${LOGDIR}" -ingestlog="${logdir}/capture.log" -echo -e "$log" >> "${ingestlog}" -_writeingestlog "audiodecision" "${audiodecision}" -_writeingestlog "cropdecision" "${cropdecision}" -_writeingestlog "cleanupdecision" "${cleanupdecision}" -_writeingestlog "formula" "${formula}" +INGESTLOG="${LOGDIR}/capture.log" +echo -e "${LOG}" >> "${INGESTLOG}" +_writeingestlog "audiodecision" "${AUDIODECISION}" +_writeingestlog "cropdecision" "${CROPDECISION}" +_writeingestlog "cleanupdecision" "${CLEANUPDECISION}" +_writeingestlog "formula" "${FORMULA}" _writeingestlog "ingest_process_dir" "${OUTDIR_INGESTFILE}" _writeingestlog "ingest_process_dir_freespace" "$(df -h "${OUTDIR_INGESTFILE}" | tail -n1 | awk '{print $4}')" _writeingestlog "computer_name" "$(uname -n)" _writeingestlog "user_name" "$(whoami)" _writeingestlog "operating_system_version" "$(uname -v)" -_writeingestlog "datetime_start" "$(get_iso8601)" +_writeingestlog "datetime_start" "$(_get_iso8601)" -if [ "${intime}" ] ; then - _writeingestlog "intime" "${intime}" +if [ "${INTIME}" ] ; then + _writeingestlog "intime" "${INTIME}" fi -if [ "${outtime}" ] ; then - _writeingestlog "outtime" "${outtime}" +if [ "${OUTTIME}" ] ; then + _writeingestlog "outtime" "${OUTTIME}" fi # rsync -from=$(_get_filesystem "${input}") -to=$(_get_filesystem "${objectsdir}/") +FROM=$(_get_filesystem "${INPUT}") +TO=$(_get_filesystem "${OBJECTSDIR}/") # make sure the input is still there -if [ ! -f "${input}" ] ; then - report -wt "The input file is no longer available! Where did $(basename "${input}") go? Please redo." +if [ ! -f "${INPUT}" ] ; then + _report -wt "The input file is no longer available! Where did $(basename "${INPUT}") go? Please redo." # clean up queue - [ "${priority}" == "put in queue" ] && _cleanup + [ "${PRIORITY}" == "put in queue" ] && _cleanup exit 1 fi # either rsync or mv the input into the package -if [ "${from}" == "${to}" -a "${cleanup}" == "Y" ] ; then - report -dt "Because ${input} and ${objectsdir} are on the same filesystem and preservation mode is enabled we will mv rather than rsync." - _run_critical mv -v -n "${input}" "${objectsdir}/" +if [ "${FROM}" == "${TO}" -a "${CLEANUP_CHOICE}" == "Y" ] ; then + _report -dt "Because ${INPUT} and ${OBJECTSDIR} are on the same filesystem and preservation mode is enabled we will mv rather than rsync." + _run_critical mv -v -n "${INPUT}" "${OBJECTSDIR}/" else - report -dt "STATUS Copying the original file to library storage at ${objectsdir}." - _run_critical rsync -rt --progress --log-file="${logdir}/rsync_$(get_iso8601_c)_$(basename $0)_${version}.txt" "${input}" "${objectsdir}/" + _report -dt "STATUS Copying the original file to library storage at ${OBJECTSDIR}." + _run_critical rsync -rt --progress --log-file="${LOGDIR}/rsync_$(_get_iso8601_c)_$(basename ${0})_${VERSION}.txt" "${INPUT}" "${OBJECTSDIR}/" fi # if in preservation mode then handle trimmed materials -if [ "${preservation_mode}" = "Y" ] ; then - if [ ! "${#trimmed[@]}" = 0 ] ; then - trimmed_materials_dir="${objectsdir}/trimmed_materials" - _mkdir2 "${trimmed_materials_dir}" - _run_critical rsync -rt --progress --log-file="${logdir}/rsync_$(get_iso8601_c)_$(basename $0)_${version}.txt" "${trimmed[@]}" "${trimmed_materials_dir}/" +if [ "${PRESERVATION_MODE}" = "Y" ] ; then + if [ ! "${#TRIMMED[@]}" = 0 ] ; then + TRIMMED_MATERIALS_DIR="${OBJECTSDIR}/trimmed_materials" + _mkdir2 "${TRIMMED_MATERIALS_DIR}" + _run_critical rsync -rt --progress --log-file="${LOGDIR}/rsync_$(_get_iso8601_c)_$(basename ${0})_${VERSION}.txt" "${TRIMMED[@]}" "${TRIMMED_MATERIALS_DIR}/" fi - makelossless "${OUTDIR_INGESTFILE}/${mediaid}" + makelossless "${OUTDIR_INGESTFILE}/${MEDIAID}" fi # make copy for broadcast -unset makebroadcastopts -[ "${audiodecision}" == "Only use left of the first audio track [for 21st Century]" -o "${audiodecision}" == "left" ] && makebroadcastopts+=(-l) -[ "${audiodecision}" == "Only use right of the first audio track" ] && makebroadcastopts+=(-r) -[ "${cropdecision}" == "Examine the video and auto-crop out black borders (slower)" ] && makebroadcastopts+=(-c) -"${scriptdir}/makebroadcast" "${makebroadcastopts[@]}" "${OUTDIR_INGESTFILE}/${mediaid}" +unset MAKEBROADCASTOPTS +[ "${AUDIODECISION}" == "Only use left of the first audio track [for 21st Century]" -o "${AUDIODECISION}" == "left" ] && MAKEBROADCASTOPTS+=(-l) +[ "${AUDIODECISION}" == "Only use right of the first audio track" ] && MAKEBROADCASTOPTS+=(-r) +[ "${CROPDECISION}" == "Examine the video and auto-crop out black borders (slower)" ] && MAKEBROADCASTOPTS+=(-c) +"${SCRIPTDIR}/makebroadcast" "${MAKEBROADCASTOPTS[@]}" "${OUTDIR_INGESTFILE}/${MEDIAID}" # upload broadcast copy -if [ "${deliverytoomneon}" == "Y" ] ; then - report -dt "STATUS Uploading ${objectsdir}/service/${mediaid%.*}.mov to the OMNEON." - "${scriptdir}/uploadomneon" "${objectsdir}/service/${mediaid%.*}.mov" - email_delivery "${MAKEBROADCAST_DELIVERY_EMAIL_TO}" +if [ "${DELIVERYTOOMNEON}" == "Y" ] ; then + _report -dt "STATUS Uploading ${OBJECTSDIR}/service/${MEDIAID%.*}.mov to the OMNEON." + "${SCRIPTDIR}/uploadomneon" "${OBJECTSDIR}/service/${MEDIAID%.*}.mov" + _email_delivery "${MAKEBROADCAST_DELIVERY_EMAIL_TO}" fi # make access copies -if [ "${makeaccesscopies}" == "Y" ] ; then - report -dt "STATUS Making access copies." +if [ "${MAKEACCESSCOPIES}" == "Y" ] ; then + _report -dt "STATUS Making access copies." # makemp3 - "${scriptdir}/makemp3" "${OUTDIR_INGESTFILE}/${mediaid}" + "${SCRIPTDIR}/makemp3" "${OUTDIR_INGESTFILE}/${MEDIAID}" # makeframes - unset makeframesopts - [ "$deliveraccesscopies" = "Y" ] && makeframesopts=(-d "$YOUTUBEDELIVER") - "${scriptdir}/makeframes" "${makeframesopts[@]}" "$OUTDIR_INGESTFILE/$mediaid" + unset MAKEFRAMESOPTS + [ "${DELIVERACCESSCOPIES}" = "Y" ] && MAKEFRAMESOPTS=(-d "${YOUTUBEDELIVER}") + "${SCRIPTDIR}/makeframes" "${MAKEFRAMESOPTS[@]}" "${OUTDIR_INGESTFILE}/${MEDIAID}" # makeyoutube - unset makeyoutubeopts - [ "$deliveraccesscopies" = "Y" ] && makeyoutubeopts=(-Y -d "$YOUTUBEDELIVER") - "${scriptdir}/makeyoutube" "${makeyoutubeopts[@]}" "$OUTDIR_INGESTFILE/$mediaid" + unset MAKEYOUTUBEOPTS + [ "${DELIVERACCESSCOPIES}" = "Y" ] && MAKEYOUTUBEOPTS=(-Y -d "${YOUTUBEDELIVER}") + "${SCRIPTDIR}/makeyoutube" "${MAKEYOUTUBEOPTS[@]}" "${OUTDIR_INGESTFILE}/${MEDIAID}" # makepodcast - if [ $(echo "$mediaid" | grep -E "${REGEX4PODCAST}") ] ; then - report -dt "${mediaid} qualifies for podcast creation." - unset makepodcastopts - [ "$deliveraccesscopies" == "Y" ] && makepodcastopts=(-d "$PODCASTDELIVER") - "${scriptdir}/makepodcast" "${makepodcastopts[@]}" "$OUTDIR_INGESTFILE/$mediaid" + if [ $(echo "${MEDIAID}" | grep -E "${REGEX4PODCAST}") ] ; then + _report -dt "${MEDIAID} qualifies for podcast creation." + unset MAKEPODCASTOPTS + [ "${DELIVERACCESSCOPIES}" == "Y" ] && MAKEPODCASTOPTS=(-d "${PODCASTDELIVER}") + "${SCRIPTDIR}/makepodcast" "${MAKEPODCASTOPTS[@]}" "${OUTDIR_INGESTFILE}/${MEDIAID}" else - report -dt "${mediaid} does NOT qualify for podcast creation, skipping." + _report -dt "${MEDIAID} does NOT qualify for podcast creation, skipping." fi # makedvd - "${scriptdir}/makedvd" "${OUTDIR_INGESTFILE}/${mediaid}" + "${SCRIPTDIR}/makedvd" "${OUTDIR_INGESTFILE}/${MEDIAID}" fi # makemetadata -"${scriptdir}/makemetadata" "$OUTDIR_INGESTFILE/$mediaid" +"${SCRIPTDIR}/makemetadata" "${OUTDIR_INGESTFILE}/${MEDIAID}" # checksums -if [ "$dochecksums" = "Y" ] ; then - "${scriptdir}/checksumpackage" "$OUTDIR_INGESTFILE/$mediaid" +if [ "${DOCHECKSUMS}" = "Y" ] ; then + "${SCRIPTDIR}/checksumpackage" "${OUTDIR_INGESTFILE}/${MEDIAID}" fi # more logging -logdir="${OUTDIR_INGESTFILE}/${mediaid}/metadata/submissionDocumentation/logs" -_writeingestlog "datetime_end" "$(get_iso8601)" +LOGDIR="${OUTDIR_INGESTFILE}/${MEDIAID}/metadata/submissionDocumentation/logs" +_writeingestlog "datetime_end" "$(_get_iso8601)" # move and cleanup -if [ "${deliverytoaipstorage}" == "Y" ] ; then - rsync -rt --progress --remove-source-files "${OUTDIR_INGESTFILE}/${mediaid}" "${AIP_STORAGE}/" - rsync_err="$?" - [ $(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}" +if [ "${DELIVERYTOAIPSTORAGE}" == "Y" ] ; then + rsync -rt --progress --remove-source-files "${OUTDIR_INGESTFILE}/${MEDIAID}" "${AIP_STORAGE}/" + RSYNC_ERR="${?}" + [ $(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." +if [ "${CLEANUP_CHOICE}" == "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." - _run rm -f "${input}" + _report -dt "Removing the source file from ${INPUT} as requested." + _run rm -f "${INPUT}" fi fi # clean up queue -[ "${priority}" == "put in queue" ] && _remove_mediaid_from_queue +[ "${PRIORITY}" == "put in queue" ] && _remove_mediaid_from_queue _log -e diff --git a/makebroadcast b/makebroadcast index f2014e19..3830df91 100755 --- a/makebroadcast +++ b/makebroadcast @@ -4,21 +4,21 @@ # v 1.2 revert to mov and ffmbc # v 1.3 revert back to ffmpeg # v 1.4 adjust handling volume adjustment argument -version="1.4" +VERSION="1.4" VOLADJUST="Y" -scriptdir=$(dirname $(which "${0}")) -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; -dependencies=(ffmpeg ffprobe) +SCRIPTDIR=$(dirname $(which "${0}")) +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; +DEPENDENCIES=(ffmpeg ffprobe) _initialize_make -suffix="" -extension="mov" -relativepath="service" +SUFFIX="" +EXTENSION="mov" +RELATIVEPATH="service" _usage(){ echo - echo "$(basename "${0}") ${version}" + echo "$(basename "${0}") ${VERSION}" echo "This application will create a file suitable for broadcast or editing from a video file or package input with the following options." - echo "Dependencies: ${dependencies[@]}" + echo "Dependencies: ${DEPENDENCIES[@]}" echo "Usage: $(basename "${0}") [ -l ] [ -r ] [ -c ] fileorpackage1 [ fileorpackage2 ...]" echo " -F (apply a formula, override default settings)" echo " -l (only use the left channel of the first audio track)" @@ -38,205 +38,205 @@ _usage(){ # command-line options to set mediaid and original variables OPTIND=1 -while getopts ":F:lrcv:o:d:e:E:nh" opt ; do - case "${opt}" in - F) formula="${OPTARG}";; - l) audiomap="L";; - r) audiomap="R";; - c) cropdetect="Y" ;; +while getopts ":F:lrcv:o:d:e:E:nh" OPT ; do + case "${OPT}" in + F) FORMULA="${OPTARG}";; + l) AUDIOMAP="L";; + r) AUDIOMAP="R";; + c) CROPDETECT="Y" ;; v) VOLADJUST="${OPTARG}";; - o) outputdir_forced="$OPTARG" && _check_outputdir_forced ;; - d) deliverdir="$OPTARG" && check_deliverdir ;; - e) emailaddress_delivery="$OPTARG" && check_emailaddress "${emailaddress_delivery}" ;; - E) emailaddress_outcome="$OPTARG" && check_emailaddress "${emailaddress_outcome}" ;; + o) OUTPUTDIR_FORCED="${OPTARG}" && _check_outputdir_forced ;; + d) DELIVERDIR="${OPTARG}" && _check_deliverdir ;; + e) EMAILADDRESS_DELIVERY="${OPTARG}" && check_emailaddress "${EMAILADDRESS_DELIVERY}" ;; + E) EMAILADDRESS_OUTCOME="${OPTARG}" && check_emailaddress "${EMAILADDRESS_OUTCOME}" ;; n) DRYRUN=true;; h) _usage ;; - *) echo "bad option -$OPTARG" ; _usage ;; - :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; + *) echo "bad option -${OPTARG}" ; _usage ;; + :) echo "Option -${OPTARG} requires an argument" ; exit 1 ;; esac done shift $(( ${OPTIND} - 1 )) while [ "${*}" != "" ] ; do # get context about the input - input="${1}" + INPUT="${1}" shift - if [ -z "${outputdir_forced}" ] ; then - [ -d "${input}" ] && { outputdir="${input}/objects/${relativepath}" && logdir="${input}/metadata/submissionDocumentation/logs" ;}; - [ -f "${input}" ] && { outputdir=$(dirname "${input}")"/${relativepath}" && logdir="$(dirname "${input}")/${relativepath}/logs" ;}; - [ ! "${outputdir}" ] && { outputdir="${input}/objects/${relativepath}" && logdir="${input}/metadata/submissionDocumentation/logs" ;}; + if [ -z "${OUTPUTDIR_FORCED}" ] ; then + [ -d "${INPUT}" ] && { OUTPUTDIR="${INPUT}/objects/${RELATIVEPATH}" && LOGDIR="${INPUT}/metadata/submissionDocumentation/logs" ;}; + [ -f "${INPUT}" ] && { OUTPUTDIR=$(dirname "${INPUT}")"/${RELATIVEPATH}" && LOGDIR="$(dirname "${INPUT}")/${RELATIVEPATH}/logs" ;}; + [ ! "${OUTPUTDIR}" ] && { OUTPUTDIR="${INPUT}/objects/${RELATIVEPATH}" && LOGDIR="${INPUT}/metadata/submissionDocumentation/logs" ;}; else - outputdir="${outputdir_forced}" - logdir="${outputdir}/logs" + OUTPUTDIR="${OUTPUTDIR_FORCED}" + LOGDIR="${OUTPUTDIR}/logs" fi - _find_input "${input}" - mediaid=$(basename "${input}" | cut -d. -f1) - ingestlog="${logdir}/capture.log" + _find_input "${INPUT}" + MEDIAID=$(basename "${INPUT}" | cut -d. -f1) + INGESTLOG="${LOGDIR}/capture.log" _set_up_output # clear local arrays - intime="" - outtime="" + INTIME="" + OUTTIME="" audio_adjustment="" - unset inputoptions - unset middleoptions - unset middleoptionsxdcam - unset middleoptionsimx - unset audiomapping_ffmpeg - filterchain_start="" - get_videostreamcount "${sourcefile}" - get_audiostreamcount "${sourcefile}" + unset INPUTOPTIONS + unset MIDDLEOPTIONS + unset MIDDLEOPTIONSXDCAM + unset MIDDLEOPTIONSIMX + unset AUDIOMAPPING_FFMPEG + FILTERCHAIN_START="" + _get_videostreamcount "${SOURCEFILE}" + _get_audiostreamcount "${SOURCEFILE}" if [[ "${VIDEOSTREAMCOUNT}" > 0 ]] ; then # get information on the input - get_sar "${sourcefile}" - if [ "${cropdetect}" = "Y" ] ; then - get_cropdetection "${sourcefile}" - filterchain_start="${filterchain_start}${CROPADJ}," - width=$(echo "${CROPADJ}" | cut -d= -f2 | cut -d: -f1) - height=$(echo "${CROPADJ}" | cut -d= -f2 | cut -d: -f2) - dar="(${width}/${height})*${sar}" + _get_sar "${SOURCEFILE}" + if [ "${CROPDETECT}" = "Y" ] ; then + _get_cropdetection "${SOURCEFILE}" + FILTERCHAIN_START="${FILTERCHAIN_START}${CROPADJ}," + WIDTH=$(echo "${CROPADJ}" | cut -d= -f2 | cut -d: -f1) + HEIGHT=$(echo "${CROPADJ}" | cut -d= -f2 | cut -d: -f2) + DAR="(${WIDTH}/${HEIGHT})*${SAR}" else - get_width "${sourcefile}" - get_height "${sourcefile}" - get_dar "${sourcefile}" + _get_width "${SOURCEFILE}" + _get_height "${SOURCEFILE}" + _get_dar "${SOURCEFILE}" fi # set in and out times if used - if [[ -f "${ingestlog}" && "${isobject}" = "Y" ]] ; then - if [ ! ${formula} ] ; then - formula=$(_readingestlog "formula") + if [[ -f "${INGESTLOG}" && "${ISOBJECT}" = "Y" ]] ; then + if [ ! "${FORMULA}" ] ; then + FORMULA=$(_readingestlog "FORMULA") fi - intime=$(_readingestlog "intime") - outtime=$(_readingestlog "outtime") - if [[ "${intime}" ]] ; then - report -dt "ATTENTION: Transcoding will use intime (${intime}) during transcoding." - inputoptions+=(-seek_timestamp 1) - middleoptions+=(-ss "${intime}") + INTIME=$(_readingestlog "intime") + OUTTIME=$(_readingestlog "outtime") + if [[ "${INTIME}" ]] ; then + _report -dt "ATTENTION: Transcoding will use intime (${INTIME}) during transcoding." + INPUTOPTIONS+=(-seek_timestamp 1) + MIDDLEOPTIONS+=(-ss "${INTIME}") fi - if [[ "${outtime}" ]] ; then - report -dt "ATTENTION: Transcoding will use outtime (${outtime}) during transcoding." - middleoptions+=(-to "${outtime}") + if [[ "${OUTTIME}" ]] ; then + _report -dt "ATTENTION: Transcoding will use outtime (${OUTTIME}) during transcoding." + MIDDLEOPTIONS+=(-to "${OUTTIME}") fi fi #options for either xdcam or imx - middleoptions+=(-r ntsc) - middleoptions+=(-c:v mpeg2video) - middleoptions+=(-intra_vlc 1) - middleoptions+=(-non_linear_quant 1) - middleoptions+=(-qmin 1) - middleoptions+=(-dc 10) - middleoptions+=(-lmin QP2LAMBDA) - middleoptions+=(-ps 1) - middleoptions+=(-flags +ildct+ilme) - middleoptions+=(-pix_fmt yuv422p) - middleoptions+=(-metadata:s:v:0 timecode=00:00:00.00) + MIDDLEOPTIONS+=(-r ntsc) + MIDDLEOPTIONS+=(-c:v mpeg2video) + MIDDLEOPTIONS+=(-intra_vlc 1) + MIDDLEOPTIONS+=(-non_linear_quant 1) + MIDDLEOPTIONS+=(-qmin 1) + MIDDLEOPTIONS+=(-dc 10) + MIDDLEOPTIONS+=(-lmin QP2LAMBDA) + MIDDLEOPTIONS+=(-ps 1) + MIDDLEOPTIONS+=(-flags +ildct+ilme) + MIDDLEOPTIONS+=(-pix_fmt yuv422p) + MIDDLEOPTIONS+=(-metadata:s:v:0 timecode=00:00:00.00) #xdcam options - middleoptionsxdcam+=(-s 1920x1080) - middleoptionsxdcam+=(-vtag xd5b) - middleoptionsxdcam+=(-aspect 16:9) - middleoptionsxdcam+=(-q:v 1) - middleoptionsxdcam+=(-qmax 8) - middleoptionsxdcam+=(-g 15) - middleoptionsxdcam+=(-bf 2) - middleoptionsxdcam+=(-b:v 50M) - middleoptionsxdcam+=(-maxrate:v 50M) - middleoptionsxdcam+=(-minrate:v 50M) - middleoptionsxdcam+=(-bufsize 17825792) - middleoptionsxdcam+=(-rc_init_occupancy 17825792) + MIDDLEOPTIONSXDCAM+=(-s 1920x1080) + MIDDLEOPTIONSXDCAM+=(-vtag xd5b) + MIDDLEOPTIONSXDCAM+=(-aspect 16:9) + MIDDLEOPTIONSXDCAM+=(-q:v 1) + MIDDLEOPTIONSXDCAM+=(-qmax 8) + MIDDLEOPTIONSXDCAM+=(-g 15) + MIDDLEOPTIONSXDCAM+=(-bf 2) + MIDDLEOPTIONSXDCAM+=(-b:v 50M) + MIDDLEOPTIONSXDCAM+=(-maxrate:v 50M) + MIDDLEOPTIONSXDCAM+=(-minrate:v 50M) + MIDDLEOPTIONSXDCAM+=(-bufsize 17825792) + MIDDLEOPTIONSXDCAM+=(-rc_init_occupancy 17825792) # imx options - middleoptionsimx+=(-aspect 4:3) - middleoptionsimx+=(-qmax 12) - middleoptionsimx+=(-g 1) - middleoptionsimx+=(-top 1) - middleoptionsimx+=(-intra) - middleoptionsimx+=(-b:v 30M) - middleoptionsimx+=(-maxrate:v 30M) - middleoptionsimx+=(-minrate:v 30M) - middleoptionsimx+=(-bufsize 1001000) - middleoptionsimx+=(-rc_init_occupancy 1001000) - middleoptionsimx+=(-rc_max_vbv_use 1) - middleoptionsimx+=(-rc_min_vbv_use 1) - middleoptionsimx+=(-rc_buf_aggressivity 0.25) - middleoptionsimx+=(-vbsf imxdump) - middleoptionsimx+=(-tag:v mx3n) + MIDDLEOPTIONSIMX+=(-aspect 4:3) + MIDDLEOPTIONSIMX+=(-qmax 12) + MIDDLEOPTIONSIMX+=(-g 1) + MIDDLEOPTIONSIMX+=(-top 1) + MIDDLEOPTIONSIMX+=(-intra) + MIDDLEOPTIONSIMX+=(-b:v 30M) + MIDDLEOPTIONSIMX+=(-maxrate:v 30M) + MIDDLEOPTIONSIMX+=(-minrate:v 30M) + MIDDLEOPTIONSIMX+=(-bufsize 1001000) + MIDDLEOPTIONSIMX+=(-rc_init_occupancy 1001000) + MIDDLEOPTIONSIMX+=(-rc_max_vbv_use 1) + MIDDLEOPTIONSIMX+=(-rc_min_vbv_use 1) + MIDDLEOPTIONSIMX+=(-rc_buf_aggressivity 0.25) + MIDDLEOPTIONSIMX+=(-vbsf imxdump) + MIDDLEOPTIONSIMX+=(-tag:v mx3n) # decide on an output codec, aspect ratio, and padding strategy - darratio=$(echo "scale=3 ; ${dar}" | bc) - if [ "${formula}" = "tff" ] ; then - filterchain_start="${filterchain_start}setfield=tff," - elif [ "${formula}" = "bff" ] ; then - filterchain_start="${filterchain_start}setfield=bff," + DARRATIO=$(echo "scale=3 ; ${DAR}" | bc) + if [ "${FORMULA}" = "tff" ] ; then + FILTERCHAIN_START="${FILTERCHAIN_START}setfield=tff," + elif [ "${FORMULA}" = "bff" ] ; then + FILTERCHAIN_START="${FILTERCHAIN_START}setfield=bff," fi - get_fieldorder "${sourcefile}" - if [ "${fieldorder}" != "tff" ] ; then - filterchain_start="${filterchain_start}fieldorder=tff," + _get_fieldorder "${SOURCEFILE}" + if [ "${FIELDORDER}" != "tff" ] ; then + FILTERCHAIN_START="${FILTERCHAIN_START}FIELDORDER=tff," fi - if [ "${formula}" = "hds" ] ; then - middleoptions+=(-vf "${filterchain_start}scale=size=hd1080:interl=1,format=yuv422p,setsar=1/1,setdar=16/9,fps=fps=ntsc") - middleoptions+=(${middleoptionsxdcam[@]}) - elif [ "${darratio}" = "1.777" -a ! "${cropdetect}" = "Y" ] ; then - middleoptions+=(-vf "${filterchain_start}scale=size=hd1080:interl=1,format=yuv422p,setsar=1/1,setdar=16/9,fps=fps=ntsc") - middleoptions+=(${middleoptionsxdcam[@]}) - elif [ $(echo "scale=3 ; ${darratio} > (16/9)" | bc -l) = 1 ] ; then - middleoptions+=(-vf "${filterchain_start}pad=${width}:${width}*(9/16)*(${sar}):(ow-${width})/2:(oh-${height})/2,scale=size=hd1080:interl=1") - middleoptions+=(${middleoptionsxdcam[@]}) - elif [ $(echo "scale=3 ; $darratio > (3/2)" | bc -l) = 1 ] ; then - middleoptions+=(-vf "${filterchain_start}pad=${height}*(16/9)/(${sar}):${height}:(ow-${width})/2:(oh-${height})/2,scale=size=hd1080:interl=1") - middleoptions+=(${middleoptionsxdcam[@]}) - elif [ "$width" = "720" -a "$height" = "480" -a $(echo "scale=3 ; $darratio < (3/2)" | bc -l) = 1 -a ! "$cropdetect" = "Y" ] ; then - middleoptions+=(-vf ${filterchain_start}pad=720:512:0:24,setsar=1/1,setdar=4/3) - middleoptions+=(${middleoptionsimx[@]}) - elif [ "${height}" -eq "486" -a "${width}" -eq "720" ] ; then - middleoptions+=(-vf "${filterchain_start}crop=720:480:0:4,pad=720:512:0:24,setsar=1/1,setdar=4/3") - middleoptions+=(${middleoptionsimx[@]}) - elif [ "${height}" -eq "512" -a "${width}" -eq "720" ] ;then - middleoptions+=(-vf "${filterchain_start}crop=720:480:0:32,pad=720:512:0:24,setsar=1/1,setdar=4/3") - middleoptions+=(${middleoptionsimx[@]}) + if [ "${FORMULA}" = "hds" ] ; then + MIDDLEOPTIONS+=(-vf "${FILTERCHAIN_START}scale=size=hd1080:interl=1,format=yuv422p,setsar=1/1,setdar=16/9,fps=fps=ntsc") + MIDDLEOPTIONS+=("${MIDDLEOPTIONSXDCAM[@]}") + elif [ "${DARRATIO}" = "1.777" -a ! "${CROPDETECT}" = "Y" ] ; then + MIDDLEOPTIONS+=(-vf "${FILTERCHAIN_START}scale=size=hd1080:interl=1,format=yuv422p,setsar=1/1,setdar=16/9,fps=fps=ntsc") + MIDDLEOPTIONS+=("${MIDDLEOPTIONSXDCAM[@]}") + elif [ $(echo "scale=3 ; ${DARRATIO} > (16/9)" | bc -l) = 1 ] ; then + MIDDLEOPTIONS+=(-vf "${FILTERCHAIN_START}pad=${WIDTH}:${WIDTH}*(9/16)*(${SAR}):(ow-${WIDTH})/2:(oh-${HEIGHT})/2,scale=size=hd1080:interl=1") + MIDDLEOPTIONS+=("${MIDDLEOPTIONSXDCAM[@]}") + elif [ $(echo "scale=3 ; $DARRATIO > (3/2)" | bc -l) = 1 ] ; then + MIDDLEOPTIONS+=(-vf "${FILTERCHAIN_START}pad=${HEIGHT}*(16/9)/(${SAR}):${HEIGHT}:(ow-${WIDTH})/2:(oh-${HEIGHT})/2,scale=size=hd1080:interl=1") + MIDDLEOPTIONS+=("${MIDDLEOPTIONSXDCAM[@]}") + elif [ "${WIDTH}" = "720" -a "${HEIGHT}" = "480" -a $(echo "scale=3 ; ${DARRATIO} < (3/2)" | bc -l) = 1 -a ! "${CROPDETECT}" = "Y" ] ; then + MIDDLEOPTIONS+=(-vf "${FILTERCHAIN_START}"pad=720:512:0:24,setsar=1/1,setdar=4/3) + MIDDLEOPTIONS+=("${MIDDLEOPTIONSIMX[@]}") + elif [ "${HEIGHT}" -eq "486" -a "${WIDTH}" -eq "720" ] ; then + MIDDLEOPTIONS+=(-vf "${FILTERCHAIN_START}crop=720:480:0:4,pad=720:512:0:24,setsar=1/1,setdar=4/3") + MIDDLEOPTIONS+=("${MIDDLEOPTIONSIMX[@]}") + elif [ "${HEIGHT}" -eq "512" -a "${WIDTH}" -eq "720" ] ;then + MIDDLEOPTIONS+=(-vf "${FILTERCHAIN_START}crop=720:480:0:32,pad=720:512:0:24,setsar=1/1,setdar=4/3") + MIDDLEOPTIONS+=("${MIDDLEOPTIONSIMX[@]}") else - middleoptions+=(-vf "${filterchain_start}scale=720:480,pad=720:512:0:24,setsar=1/1,setdar=4/3") - middleoptions+=(${middleoptionsimx[@]}) + MIDDLEOPTIONS+=(-vf "${FILTERCHAIN_START}scale=720:480,pad=720:512:0:24,setsar=1/1,setdar=4/3") + MIDDLEOPTIONS+=("${MIDDLEOPTIONSIMX[@]}") fi fi if [[ "${AUDIOSTREAMCOUNT}" > 0 ]] ; then - get_audio_index "${sourcefile}" - if [ "${audiomap}" = "L" ] ; then - audiomapping_ffmpeg=(-map_channel 0.${audio_index_1}.0) - elif [ "${audiomap}" = "R" ] ; then - audiomapping_ffmpeg=(-map_channel 0.${audio_index_1}.1) + _get_audio_index "${SOURCEFILE}" + if [ "${AUDIOMAP}" = "L" ] ; then + AUDIOMAPPING_FFMPEG=(-map_channel 0.${AUDIO_INDEX_1}.0) + elif [ "${AUDIOMAP}" = "R" ] ; then + AUDIOMAPPING_FFMPEG=(-map_channel 0.${AUDIO_INDEX_1}.1) else - get_audio_mapping "${sourcefile}" + _get_audio_mapping "${SOURCEFILE}" fi - middleoptions+=(${audiomapping_ffmpeg[@]}) + MIDDLEOPTIONS+=("${AUDIOMAPPING_FFMPEG[@]}") # add audio options - middleoptions+=(-acodec pcm_s24be) - middleoptions+=(-ar 48k) - middleoptions+=(-ac 2) + MIDDLEOPTIONS+=(-acodec pcm_s24be) + MIDDLEOPTIONS+=(-ar 48k) + MIDDLEOPTIONS+=(-ac 2) fi # set input options for ffmpeg - get_codectagstring "${sourcefile}" - inputoptions+=(-y) - inputoptions+=(-nostdin) - if [[ "${codec_tag_string}" == "mjp2" ]] ; then - inputoptions+=(-vcodec libopenjpeg) + _get_codectagstring "${SOURCEFILE}" + INPUTOPTIONS+=(-y) + INPUTOPTIONS+=(-nostdin) + if [[ "${CODEC_TAG_STRING}" == "mjp2" ]] ; then + INPUTOPTIONS+=(-vcodec libopenjpeg) fi # log process _prep_ffmpeg_log _prep_volume_adjustment - if [ "${concatsource}" != "" ] ; then - ffmpeginput="${concatsource}" + if [ "${CONCATSOURCE}" != "" ] ; then + FFMPEGINPUT="${CONCATSOURCE}" else - ffmpeginput="${sourcefile}" + FFMPEGINPUT="${SOURCEFILE}" fi - _run_critical ffmpeg ${inputoptions[@]} -i "${ffmpeginput}" ${middleoptions[@]} "${output}" + _run_critical ffmpeg "${INPUTOPTIONS[@]}" -i "${FFMPEGINPUT}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}" echo _summarize_make _deliver_output "${MAKEBROADCAST_DELIVERY_EMAIL_TO}" diff --git a/makedvd b/makedvd index 790cb589..b846348e 100755 --- a/makedvd +++ b/makedvd @@ -1,19 +1,19 @@ #!/bin/bash # makedvd -version="1.0" -scriptdir=$(dirname $(which "${0}")) -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; -dependencies=(ffmpeg ffprobe dvdauthor mkisofs) +VERSION="1.0" +SCRIPTDIR=$(dirname $(which "${0}")) +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; +DEPENDENCIES=(ffmpeg ffprobe dvdauthor mkisofs) _initialize_make -suffix="" -extension="iso" +SUFFIX="" +EXTENSION="iso" -usage(){ +_usage(){ echo - echo "$(basename "${0}") ${version}" + echo "$(basename "${0}") ${VERSION}" echo "This application will create a DVD .iso file from a video file or package input with the following options." - echo "Dependencies: ${dependencies[@]}" - echo "Usage: $(basename $0) [ -v dvd_label_prefix ] fileorpackage1 [ fileorpackage2 ...]" + echo "Dependencies: ${DEPENDENCIES[@]}" + echo "Usage: $(basename ${0}) [ -v dvd_label_prefix ] fileorpackage1 [ fileorpackage2 ...]" echo " -l (only use the left channel of the first audio track)" echo " -r (only use the right channel of the first audio track)" echo " -v dvdlabelprefix (optional)" @@ -26,139 +26,139 @@ usage(){ echo exit } -[ "${#}" = 0 ] && usage +[ "${#}" = 0 ] && _usage # command-line options to set mediaid and original variables OPTIND=1 -while getopts ":lrv:o:d:e:E:nth" opt ; do - case "${opt}" in - l) audiomap="L";; - r) audiomap="R";; - v) DVDLABELPREFIX="$OPTARG";; - o) outputdir_forced="$OPTARG" && _check_outputdir_forced ;; - d) deliverdir="$OPTARG" && check_deliverdir ;; - e) emailaddress_delivery="$OPTARG" && check_emailaddress "${emailaddress_delivery}" ;; - E) emailaddress_outcome="$OPTARG" && check_emailaddress "${emailaddress_outcome}" ;; +while getopts ":lrv:o:d:e:E:nth" OPT ; do + case "${OPT}" in + l) AUDIOMAP="L";; + r) AUDIOMAP="R";; + v) DVDLABELPREFIX="${OPTARG}";; + o) OUTPUTDIR_FORCED="${OPTARG}" && _check_outputdir_forced ;; + d) DELIVERDIR="${OPTARG}" && _check_deliverdir ;; + e) EMAILADDRESS_DELIVERY="${OPTARG}" && check_emailaddress "${EMAILADDRESS_DELIVERY}" ;; + E) EMAILADDRESS_OUTCOME="${OPTARG}" && check_emailaddress "${EMAILADDRESS_OUTCOME}" ;; t) TCBURN=Y;; n) DRYRUN=true;; - h) usage ;; - *) echo "bad option -$OPTARG" ; usage ;; - :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; + h) _usage ;; + *) echo "bad option -${OPTARG}" ; _usage ;; + :) echo "Option -${OPTARG} requires an argument" ; exit 1 ;; esac done shift $(( ${OPTIND} - 1 )) while [ "${*}" != "" ] ; do # get context about the input - input="${1}" + INPUT="${1}" shift - if [ -z "${outputdir_forced}" ] ; then - [ -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" ;}; + if [ -z "${OUTPUTDIR_FORCED}" ] ; then + [ -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" ;}; else - outputdir="${outputdir_forced}" - logdir="${outputdir}/logs" + OUTPUTDIR="${OUTPUTDIR_FORCED}" + LOGDIR="${OUTPUTDIR}/logs" fi - _find_input "${input}" - mediaid=$(basename "${input}" | cut -d. -f1) + _find_input "${INPUT}" + MEDIAID=$(basename "${INPUT}" | cut -d. -f1) _set_up_output # get information on the input - get_height "${sourcefile}" - get_width "${sourcefile}" - get_dar "${sourcefile}" - darratio=$(echo "scale=3 ; $dar" | bc) - if [ $(echo "scale=5 ; $darratio > 1.5" | bc -l) = 1 ] ;then - aspect="16/9" - dvdaspect="16:9" + _get_height "${SOURCEFILE}" + _get_width "${SOURCEFILE}" + _get_dar "${SOURCEFILE}" + DARRATIO=$(echo "scale=3 ; ${DAR}" | bc) + if [ $(echo "scale=5 ; ${DARRATIO} > 1.5" | bc -l) = 1 ] ;then + ASPECT="16/9" + DVDASPECT="16:9" else - aspect="4/3" - dvdaspect="4:3" + ASPECT="4/3" + DVDASPECT="4:3" fi - get_maxdvdbitrate "$sourcefile" + _get_maxdvdbitrate "${SOURCEFILE}" # clear local arrays - unset inputoptions - unset middleoptions - unset audiomapping_ffmpeg - get_videostreamcount "${sourcefile}" - get_audiostreamcount "${sourcefile}" + unset INPUTOPTIONS + unset MIDDLEOPTIONS + unset AUDIOMAPPING_FFMPEG + _get_videostreamcount "${SOURCEFILE}" + _get_audiostreamcount "${SOURCEFILE}" # encoding options - inputoptions+=" -y" - inputoptions+=(-nostdin) + INPUTOPTIONS+=" -y" + INPUTOPTIONS+=(-nostdin) if [[ "${VIDEOSTREAMCOUNT}" > 0 ]] ; then - get_codectagstring "${sourcefile}" + _get_codectagstring "${SOURCEFILE}" TIMECODEOVERLAY="" if [ "${TCBURN}" = "Y" ] ; then - _get_timecode_overlay "${sourcefile}" + _get_timecode_overlay "${SOURCEFILE}" fi - if [[ "${codec_tag_string}" == "mjp2" ]] ; then - inputoptions+=(-vcodec libopenjpeg) + if [[ "${CODEC_TAG_STRING}" == "mjp2" ]] ; then + INPUTOPTIONS+=(-vcodec libopenjpeg) fi - middleoptions+=(-r:v ntsc) - middleoptions+=(-c:v mpeg2video) - middleoptions+=(-c:a ac3) - middleoptions+=(-f dvd) - middleoptions+=(-bf 2) - middleoptions+=(-qscale:v 2) - middleoptions+=(-mbd rd) - middleoptions+=(-s 720x480) - middleoptions+=(-pix_fmt yuv420p) - middleoptions+=(-g 18) - middleoptions+=(-b:v $MAXDVDBITRATE) - middleoptions+=(-bt 400k) - middleoptions+=(-top 0) - middleoptions+=(-flags +ildct+ilme) - middleoptions+=(-maxrate $MAXDVDBITRATE) - middleoptions+=(-minrate 0) - middleoptions+=(-bufsize 3600k) - middleoptions+=(-packetsize 2048) - middleoptions+=(-muxrate 10080000) - middleoptions+=(-lmin 1) - middleoptions+=(-lmax 200000) - if [[ "${width}" == 720 && "${height}" == 486 ]] ; then - middleoptions+=(-vf "fieldorder=bff,crop=720:480:0:4,setdar=${aspect}${TIMECODEOVERLAY}" -aspect ${aspect}) - elif [[ "${width}" == 720 && "${height}" == 480 ]] ; then - middleoptions+=(-vf "fieldorder=bff,setdar=${aspect}${TIMECODEOVERLAY}" -aspect ${aspect}) - elif [[ "${width}" == 720 && "${height}" == 512 ]] ; then - middleoptions+=(-vf "fieldorder=bff,crop=720:480:0:32,setdar=${aspect}${TIMECODEOVERLAY}" -aspect ${aspect}) + MIDDLEOPTIONS+=(-r:v ntsc) + MIDDLEOPTIONS+=(-c:v mpeg2video) + MIDDLEOPTIONS+=(-c:a ac3) + MIDDLEOPTIONS+=(-f dvd) + MIDDLEOPTIONS+=(-bf 2) + MIDDLEOPTIONS+=(-qscale:v 2) + MIDDLEOPTIONS+=(-mbd rd) + MIDDLEOPTIONS+=(-s 720x480) + MIDDLEOPTIONS+=(-pix_fmt yuv420p) + MIDDLEOPTIONS+=(-g 18) + MIDDLEOPTIONS+=(-b:v "${MAXDVDBITRATE}") + MIDDLEOPTIONS+=(-bt 400k) + MIDDLEOPTIONS+=(-top 0) + MIDDLEOPTIONS+=(-flags +ildct+ilme) + MIDDLEOPTIONS+=(-maxrate "${MAXDVDBITRATE}") + MIDDLEOPTIONS+=(-minrate 0) + MIDDLEOPTIONS+=(-bufsize 3600k) + MIDDLEOPTIONS+=(-packetsize 2048) + MIDDLEOPTIONS+=(-muxrate 10080000) + MIDDLEOPTIONS+=(-lmin 1) + MIDDLEOPTIONS+=(-lmax 200000) + if [[ "${WIDTH}" == 720 && "${HEIGHT}" == 486 ]] ; then + MIDDLEOPTIONS+=(-vf "FIELDORDER=bff,crop=720:480:0:4,setdar=${ASPECT}${TIMECODEOVERLAY}" -aspect "${ASPECT}") + elif [[ "${WIDTH}" == 720 && "${HEIGHT}" == 480 ]] ; then + MIDDLEOPTIONS+=(-vf "FIELDORDER=bff,setdar=${ASPECT}${TIMECODEOVERLAY}" -aspect "${ASPECT}") + elif [[ "${WIDTH}" == 720 && "${HEIGHT}" == 512 ]] ; then + MIDDLEOPTIONS+=(-vf "FIELDORDER=bff,crop=720:480:0:32,setdar=${ASPECT}${TIMECODEOVERLAY}" -aspect "${ASPECT}") else - middleoptions+=(-vf "fieldorder=bff,scale=720:480:interl=1,setdar=${aspect}${TIMECODEOVERLAY}" -aspect ${aspect}) + MIDDLEOPTIONS+=(-vf "FIELDORDER=bff,scale=720:480:interl=1,setdar=${ASPECT}${TIMECODEOVERLAY}" -aspect "${ASPECT}") fi fi if [[ "${AUDIOSTREAMCOUNT}" > 0 ]] ; then - middleoptions+=(-b:a 448000) - middleoptions+=(-ar 48000) - get_audio_index "${sourcefile}" - if [ "${audiomap}" = "L" ] ; then - audiomapping_ffmpeg=(-map_channel 0.${audio_index_1}.0) - elif [ "${audiomap}" = "R" ] ; then - audiomapping_ffmpeg=(-map_channel 0.${audio_index_1}.1) + MIDDLEOPTIONS+=(-b:a 448000) + MIDDLEOPTIONS+=(-ar 48000) + _get_audio_index "${SOURCEFILE}" + if [ "${AUDIOMAP}" = "L" ] ; then + AUDIOMAPPING_FFMPEG=(-map_channel 0.${AUDIO_INDEX_1}.0) + elif [ "${AUDIOMAP}" = "R" ] ; then + AUDIOMAPPING_FFMPEG=(-map_channel 0.${AUDIO_INDEX_1}.1) else - get_audio_mapping "${sourcefile}" + _get_audio_mapping "${SOURCEFILE}" fi - middleoptions+=(${audiomapping_ffmpeg[@]}) + MIDDLEOPTIONS+=("${AUDIOMAPPING_FFMPEG[@]}") fi _prep_ffmpeg_log # making the initial mpeg2 for the dvd - if [ "${concatsource}" != "" ] ; then - ffmpeginput="${concatsource}" + if [ "${CONCATSOURCE}" != "" ] ; then + FFMPEGINPUT="${CONCATSOURCE}" else - ffmpeginput="${sourcefile}" + FFMPEGINPUT="${SOURCEFILE}" fi - _run_critical ffmpeg ${inputoptions[@]} -i "${ffmpeginput}" ${middleoptions[@]} "${outputdir}/${mediaid%.*}.mpeg" + _run_critical ffmpeg ${INPUTOPTIONS[@]} -i "${FFMPEGINPUT}" ${MIDDLEOPTIONS[@]} "${OUTPUTDIR}/${MEDIAID%.*}.mpeg" # Making DVD VIDEO_TS folder, chapters every 5 minutes, dvdauthor will ignore chapter markers greater than duration export VIDEO_FORMAT=NTSC - _run_critical 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" - _run rm "${outputdir}/${mediaid%.*}.mpeg" - _run_critical dvdauthor -T -o "${outputdir}/${mediaid%.*}/" + _run_critical 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" + _run rm "${OUTPUTDIR}/${MEDIAID%.*}.mpeg" + _run_critical dvdauthor -T -o "${OUTPUTDIR}/${MEDIAID%.*}/" # Making DVD image file. - volname=$(echo "${DVDLABELPREFIX}${mediaid}") - _run_critical mkisofs -f -dvd-video -udf -V "${volname:0:32}" -v -v -o "${output}" "${outputdir}/${mediaid%.*}" 2> "${logdir}/mkisofs_$(get_iso8601_c)_$(basename $0)_${version}.txt" - _run rm -r "${outputdir}/${mediaid%.*}/" + volname=$(echo "${DVDLABELPREFIX}${MEDIAID}") + _run_critical mkisofs -f -dvd-video -udf -V "${volname:0:32}" -v -v -o "${OUTPUT}" "${OUTPUTDIR}/${MEDIAID%.*}" 2> "${LOGDIR}/mkisofs_$(_get_iso8601_c)_$(basename ${0})_${VERSION}.txt" + _run rm -r "${OUTPUTDIR}/${MEDIAID%.*}/" echo _summarize_make _deliver_output diff --git a/makeflv b/makeflv index 36b09055..bbb982f6 100755 --- a/makeflv +++ b/makeflv @@ -1,22 +1,22 @@ #!/bin/bash # makeflv, makes a crappy flash file -version="1.0" -scriptdir=$(dirname $(which "${0}")) -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; -dependencies=(ffmpeg) +VERSION="1.0" +SCRIPTDIR=$(dirname $(which "${0}")) +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; +DEPENDENCIES=(ffmpeg) _initialize_make -suffix="" -extension="flv" -relativepath="access/flv" +SUFFIX="" +EXTENSION="flv" +RELATIVEPATH="access/flv" -outputdir="$HOME/Desktop/$(basename $0)" # default output directory, override with -o +OUTPUTDIR="${HOME}/Desktop/$(basename ${0})" # default output directory, override with -o -usage(){ +_usage(){ echo - echo "$(basename "${0}") ${version}" - echo "This application will create a prores/quicktime file (suitable for editing) from a video file or package input with the following options. By default the output will be written to ${outputdir}. You can override this with the -o option." - echo "Dependencies: ${dependencies[@]}" - echo "Usage: $(basename $0) [ -o /directory/to/write/to/ ] fileorpackage1 [ fileorpackage2 ...]" + echo "$(basename "${0}") ${VERSION}" + echo "This application will create a prores/quicktime file (suitable for editing) from a video file or package input with the following options. By default the output will be written to ${OUTPUTDIR}. You can override this with the -o option." + echo "Dependencies: ${DEPENDENCIES[@]}" + echo "Usage: $(basename ${0}) [ -o /directory/to/write/to/ ] fileorpackage1 [ fileorpackage2 ...]" echo " -d directory ( directory to deliver the resulting file to )" echo " -o directory ( directory to write the resulting file to )" echo " -n (dry-run mode, show the commands that would be run but don't do anything)" @@ -26,93 +26,93 @@ usage(){ echo exit } -[ "${#}" = 0 ] && usage +[ "${#}" = 0 ] && _usage # command-line options to set mediaid and original variables OPTIND=1 -while getopts ":o:d:e:E:nh" opt ; do - case "${opt}" in - o) outputdir_forced="$OPTARG" && _check_outputdir_forced ;; - d) deliverdir="$OPTARG" && check_deliverdir ;; - e) emailaddress_delivery="$OPTARG" && check_emailaddress "${emailaddress_delivery}" ;; - E) emailaddress_outcome="$OPTARG" && check_emailaddress "${emailaddress_outcome}" ;; +while getopts ":o:d:e:E:nh" OPT ; do + case "${OPT}" in + o) OUTPUTDIR_FORCED="${OPTARG}" && _check_outputdir_forced ;; + d) DELIVERDIR="${OPTARG}" && _check_deliverdir ;; + e) EMAILADDRESS_DELIVERY="${OPTARG}" && check_emailaddress "${EMAILADDRESS_DELIVERY}" ;; + E) EMAILADDRESS_OUTCOME="${OPTARG}" && check_emailaddress "${EMAILADDRESS_OUTCOME}" ;; n) DRYRUN=true;; - h) usage ;; - *) echo "bad option -$OPTARG" ; usage ;; - :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; + h) _usage ;; + *) echo "bad option -${OPTARG}" ; _usage ;; + :) echo "Option -${OPTARG} requires an argument" ; exit 1 ;; esac done shift $(( ${OPTIND} - 1 )) while [ "${*}" != "" ] ; do # get context about the input - input="${1}" + INPUT="${1}" shift - if [ -z "${outputdir_forced}" ] ; then - [ -d "${input}" ] && { outputdir="${input}/objects/${relativepath}" && logdir="${input}/metadata/submissionDocumentation/logs" ;}; - [ -f "${input}" ] && { outputdir=$(dirname "${input}")"/${relativepath}" && logdir="$(dirname "${input}")/${relativepath}/logs" ;}; - [ ! "${outputdir}" ] && { outputdir="${input}/objects/${relativepath}" && logdir="${input}/metadata/submissionDocumentation/logs" ;}; + if [ -z "${OUTPUTDIR_FORCED}" ] ; then + [ -d "${INPUT}" ] && { OUTPUTDIR="${INPUT}/objects/${RELATIVEPATH}" && LOGDIR="${INPUT}/metadata/submissionDocumentation/logs" ;}; + [ -f "${INPUT}" ] && { OUTPUTDIR=$(dirname "${INPUT}")"/${RELATIVEPATH}" && LOGDIR="$(dirname "${INPUT}")/${RELATIVEPATH}/logs" ;}; + [ ! "${OUTPUTDIR}" ] && { OUTPUTDIR="${INPUT}/objects/${RELATIVEPATH}" && LOGDIR="${INPUT}/metadata/submissionDocumentation/logs" ;}; else - outputdir="${outputdir_forced}" - logdir="${outputdir}/logs" + OUTPUTDIR="${OUTPUTDIR_FORCED}" + LOGDIR="${OUTPUTDIR}/logs" fi - _find_input "${input}" - mediaid=$(basename "${input}" | cut -d. -f1) + _find_input "${INPUT}" + MEDIAID=$(basename "${INPUT}" | cut -d. -f1) _set_up_output # clear local arrays - unset inputoptions - unset middleoptions + unset INPUTOPTIONS + unset MIDDLEOPTIONS # encoding options - get_codectagstring "${sourcefile}" - get_videostreamcount "${sourcefile}" - get_audiostreamcount "${sourcefile}" - inputoptions+=(-vsync 0) - inputoptions+=(-nostdin) + _get_codectagstring "${SOURCEFILE}" + _get_videostreamcount "${SOURCEFILE}" + _get_audiostreamcount "${SOURCEFILE}" + INPUTOPTIONS+=(-vsync 0) + INPUTOPTIONS+=(-nostdin) if [[ "${VIDEOSTREAMCOUNT}" > 0 ]] ; then - if [[ "${codec_tag_string}" == "mjp2" ]] ; then - inputoptions+=(-vcodec libopenjpeg) + if [[ "${CODEC_TAG_STRING}" == "mjp2" ]] ; then + INPUTOPTIONS+=(-vcodec libopenjpeg) fi - middleoptions+=(-map 0:v) - middleoptions+=(-c:v libx264) - middleoptions+=(-pix_fmt yuv420p) - middleoptions+=(-b:v 4500k) - middleoptions+=(-s 480x360) - middleoptions+=(-vf setdar=4/3,setsar=1/1) + MIDDLEOPTIONS+=(-map 0:v) + MIDDLEOPTIONS+=(-c:v libx264) + MIDDLEOPTIONS+=(-pix_fmt yuv420p) + MIDDLEOPTIONS+=(-b:v 4500k) + MIDDLEOPTIONS+=(-s 480x360) + MIDDLEOPTIONS+=(-vf setdar=4/3,setsar=1/1) fi if [[ "${AUDIOSTREAMCOUNT}" > 0 ]] ; then - middleoptions+=(-map 0:a) - middleoptions+=(-sample_fmt s16p) - middleoptions+=(-ar 44100) - middleoptions+=(-b:a 320k) - middleoptions+=(-ac 2) + MIDDLEOPTIONS+=(-map 0:a) + MIDDLEOPTIONS+=(-sample_fmt s16p) + MIDDLEOPTIONS+=(-ar 44100) + MIDDLEOPTIONS+=(-b:a 320k) + MIDDLEOPTIONS+=(-ac 2) fi # set in and out times if used - ingestlog="${logdir}/capture.log" - if [[ -f "${ingestlog}" && "${isobject}" = "Y" ]] ; then - intime=$(_readingestlog "intime") - outtime=$(_readingestlog "outtime") - if [[ "${intime}" ]] ; then - report -dt "ATTENTION: Transcoding will use intime (${intime}) during transcoding." - inputoptions+=(-seek_timestamp 1) - middleoptions+=(-ss "${intime}") + INGESTLOG="${LOGDIR}/capture.log" + if [[ -f "${INGESTLOG}" && "${ISOBJECT}" = "Y" ]] ; then + INTIME=$(_readingestlog "intime") + OUTTIME=$(_readingestlog "outtime") + if [[ "${INTIME}" ]] ; then + _report -dt "ATTENTION: Transcoding will use intime (${INTIME}) during transcoding." + INPUTOPTIONS+=(-seek_timestamp 1) + MIDDLEOPTIONS+=(-ss "${INTIME}") fi - if [[ "${outtime}" ]] ; then - report -dt "ATTENTION: Transcoding will use outtime (${outtime}) during transcoding." - middleoptions+=(-to "${outtime}") + if [[ "${OUTTIME}" ]] ; then + _report -dt "ATTENTION: Transcoding will use outtime (${OUTTIME}) during transcoding." + MIDDLEOPTIONS+=(-to "${OUTTIME}") fi fi _prep_ffmpeg_log - if [ "${concatsource}" != "" ] ; then - ffmpeginput="${concatsource}" + if [ "${CONCATSOURCE}" != "" ] ; then + FFMPEGINPUT="${CONCATSOURCE}" else - ffmpeginput="${sourcefile}" + FFMPEGINPUT="${SOURCEFILE}" fi - _run_critical ffmpeg ${inputoptions[@]} -i "${ffmpeginput}" ${middleoptions[@]} "${output}" + _run_critical ffmpeg "${INPUTOPTIONS[@]}" -i "${FFMPEGINPUT}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}" echo _summarize_make _deliver_output diff --git a/makeframes b/makeframes index 4b9b342a..a9ecd994 100755 --- a/makeframes +++ b/makeframes @@ -1,85 +1,85 @@ #!/bin/bash # makeframes -version="1.0" -scriptdir=$(dirname $(which "${0}")) -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; -dependencies=(ffmpeg ffprobe) +VERSION="1.0" +SCRIPTDIR=$(dirname $(which "${0}")) +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; +DEPENDENCIES=(ffmpeg ffprobe) _initialize_make -extension="tiff" +EXTENSION="tiff" # local variables IMAGECOUNT=10 -usage(){ +_usage(){ echo - echo "$(basename "${0}") ${version}" + echo "$(basename "${0}") ${VERSION}" echo "This application will create a series of still images from a video file or package input with the following options." - echo "Dependencies: ${dependencies[@]}" - echo "Usage: $(basename $0) [ -d /path/to/deliver/to/ ] fileorpackage1 [ fileorpackage2 ...]" + echo "Dependencies: ${DEPENDENCIES[@]}" + echo "Usage: $(basename ${0}) [ -d /path/to/deliver/to/ ] fileorpackage1 [ fileorpackage2 ...]" echo " -d directory ( directory to deliver the resulting file to )" echo " -n (dry-run mode, show the commands that would be run but don't do anything)" echo " -h display this help" echo exit } -[ "${#}" = 0 ] && usage +[ "${#}" = 0 ] && _usage # command-line options to set mediaid and original variables OPTIND=1 -while getopts ":d:e:E:nh" opt ; do - case "${opt}" in - d) deliverdir="$OPTARG" && check_deliverdir ;; - e) emailaddress_delivery="$OPTARG" && check_emailaddress "${emailaddress_delivery}" ;; - E) emailaddress_outcome="$OPTARG" && check_emailaddress "${emailaddress_outcome}" ;; +while getopts ":d:e:E:nh" OPT ; do + case "${OPT}" in + d) DELIVERDIR="${OPTARG}" && _check_deliverdir ;; + e) EMAILADDRESS_DELIVERY="${OPTARG}" && check_emailaddress "${EMAILADDRESS_DELIVERY}" ;; + E) EMAILADDRESS_OUTCOME="${OPTARG}" && check_emailaddress "${EMAILADDRESS_OUTCOME}" ;; n) DRYRUN=true;; - h) usage ;; - *) echo "bad option -$OPTARG" ; usage ;; - :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; + h) _usage ;; + *) echo "bad option -${OPTARG}" ; _usage ;; + :) echo "Option -${OPTARG} requires an argument" ; exit 1 ;; esac done shift $(( ${OPTIND} - 1 )) while [ "${*}" != "" ] ; do - input="${1}" - [ -d "$input" ] && { outputdir="$input/objects/access/images" && logdir="$input/metadata/submissionDocumentation/logs" ;}; - [ -f "$input" ] && { outputdir=$(dirname "$input")"/access/images" && logdir="$(dirname "$input")/access/logs" ;}; - [ ! "$outputdir" ] && { outputdir="$input/objects/access/images" && logdir="$input/metadata/submissionDocumentation/logs" ;}; - _find_input "$input" + INPUT="${1}" + [ -d "${INPUT}" ] && { OUTPUTDIR="${INPUT}/objects/access/images" && LOGDIR="${INPUT}/metadata/submissionDocumentation/logs" ;}; + [ -f "${INPUT}" ] && { OUTPUTDIR=$(dirname "${INPUT}")"/access/images" && LOGDIR="$(dirname "${INPUT}")/access/logs" ;}; + [ ! "$OUTPUTDIR" ] && { OUTPUTDIR="${INPUT}/objects/access/images" && LOGDIR="${INPUT}/metadata/submissionDocumentation/logs" ;}; + _find_input "${INPUT}" - mediaid=$(basename "${1}" | cut -d. -f1) + MEDIAID=$(basename "${1}" | cut -d. -f1) # clear local arrays - unset inputoptions + unset INPUTOPTIONS # encoding options - get_codectagstring "${sourcefile}" - inputoptions+=(-vsync 0) - inputoptions+=(-nostdin) - if [[ "${codec_tag_string}" == "mjp2" ]] ; then - inputoptions+=(-vcodec libopenjpeg) + _get_codectagstring "${SOURCEFILE}" + INPUTOPTIONS+=(-vsync 0) + INPUTOPTIONS+=(-nostdin) + if [[ "${CODEC_TAG_STRING}" == "mjp2" ]] ; then + INPUTOPTIONS+=(-vcodec libopenjpeg) fi _log -b - DURATION=$(ffprobe 2>/dev/null "${sourcefile}" -show_format | grep duration | cut -d= -f2) - _run_critical mkdir -p "$outputdir" - for (( IMAGENUMBER=1; IMAGENUMBER<=$IMAGECOUNT; IMAGENUMBER++)) ; do - START=$(echo "( $DURATION / ( $IMAGECOUNT + 1 )) * $IMAGENUMBER" | bc) - suffix="_${IMAGENUMBER}" + DURATION=$(ffprobe 2>/dev/null "${SOURCEFILE}" -show_format | grep duration | cut -d= -f2) + _run_critical mkdir -p "${OUTPUTDIR}" + for (( IMAGENUMBER=1; IMAGENUMBER<=${IMAGECOUNT}; IMAGENUMBER++)) ; do + START=$(echo "( ${DURATION} / ( ${IMAGECOUNT} + 1 )) * ${IMAGENUMBER}" | bc) + SUFFIX="_${IMAGENUMBER}" _set_up_output - report -d "Making frame $IMAGENUMBER of $IMAGECOUNT - dur:${DURATION} start:${START} - $output" + _report -d "Making frame ${IMAGENUMBER} of ${IMAGECOUNT} - dur:${DURATION} start:${START} - ${OUTPUT}" _prep_ffmpeg_log -q - if [ "${concatsource}" != "" ] ; then - ffmpeginput="${concatsource}" + if [ "${CONCATSOURCE}" != "" ] ; then + FFMPEGINPUT="${CONCATSOURCE}" else - ffmpeginput="${sourcefile}" + FFMPEGINPUT="${SOURCEFILE}" fi - _run_critical ffmpeg -y ${inputoptions[@]} -v warning -ss "$START" -i "${ffmpeginput}" -vf yadif,thumbnail=100 -frames:v 1 "$output" + _run_critical ffmpeg -y ${INPUTOPTIONS[@]} -v warning -ss "$START" -i "${FFMPEGINPUT}" -vf yadif,thumbnail=100 -frames:v 1 "${OUTPUT}" done echo - if [ -d "${deliverdir}" ] ; then - report -dt "Delivering output" - _run mkdir -p "${deliverdir}/${mediaid}_images/" - _run cp -av "${outputdir}/" "${deliverdir}/${mediaid}_images/" + if [ -d "${DELIVERDIR}" ] ; then + _report -dt "Delivering output" + _run mkdir -p "${DELIVERDIR}/${MEDIAID}_images/" + _run cp -av "${OUTPUTDIR}/" "${DELIVERDIR}/${MEDIAID}_images/" fi shift _log -e diff --git a/makelossless b/makelossless index 1891e9d4..915553c6 100755 --- a/makelossless +++ b/makelossless @@ -1,104 +1,104 @@ #!/bin/bash # makelossless -version="1.0" -scriptdir=$(dirname $(which "${0}")) -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; -dependencies=(ffmpeg ffprobe mediainfo) +VERSION="1.0" +SCRIPTDIR=$(dirname $(which "${0}")) +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; +DEPENDENCIES=(ffmpeg ffprobe mediainfo) _initialize_make -usage(){ +_usage(){ echo - echo "$(basename "${0}") ${version}" + echo "$(basename "${0}") ${VERSION}" echo "This application will losslessly transcode a video file or package input with the following options." - echo "Dependencies: ${dependencies[@]}" - echo "Usage: $(basename $0) fileorpackage1 [ fileorpackage2 ...]" + echo "Dependencies: ${DEPENDENCIES[@]}" + echo "Usage: $(basename ${0}) fileorpackage1 [ fileorpackage2 ...]" echo " -j (use lossless jpeg2000 instead of ffv1 version 3)" echo " -n (dry-run mode, show the commands that would be run but don't do anything)" echo " -h display this help" echo exit } -[ "${#}" = 0 ] && usage +[ "${#}" = 0 ] && _usage # command-line options to set mediaid and original variables OPTIND=1 -while getopts ":jnh" opt ; do - case "${opt}" in - j) jpeg2000mode="Y";; +while getopts ":jnh" OPT ; do + case "${OPT}" in + j) JPEG2000MODE="Y";; n) DRYRUN=true;; - h) usage ;; - *) echo "bad option -$OPTARG" ; usage ;; - :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; + h) _usage ;; + *) echo "bad option -${OPTARG}" ; _usage ;; + :) echo "Option -${OPTARG} requires an argument" ; exit 1 ;; esac done shift $(( ${OPTIND} - 1 )) while [ "${*}" != "" ] ; do # get context about the input - input="${1}" - [ -d "${input}" ] && logdir="${input}/metadata/submissionDocumentation/logs" - [ -f "${input}" ] && logdir="$(dirname "${input}")/lossless/logs" - [ ! "${logdir}" ] && logdir="${input}/metadata/submissionDocumentation/logs" + INPUT="${1}" + [ -d "${INPUT}" ] && LOGDIR="${INPUT}/metadata/submissionDocumentation/logs" + [ -f "${INPUT}" ] && LOGDIR="$(dirname "${INPUT}")/lossless/logs" + [ ! "${LOGDIR}" ] && LOGDIR="${INPUT}/metadata/submissionDocumentation/logs" - find "${input}" -type f \( -iname "*.mov" -o -iname "*.avi" -o -iname "*.mxf" \) -print0 | while read -d $'\0' sourcefile ; do - outputdir=$(dirname "${sourcefile}") - sourcefilename=$(basename "${sourcefile}") + find "${INPUT}" -type f \( -iname "*.mov" -o -iname "*.avi" -o -iname "*.mxf" \) -print0 | while read -d $'\0' SOURCEFILE ; do + OUTPUTDIR=$(dirname "${SOURCEFILE}") + SOURCEFILENAME=$(basename "${SOURCEFILE}") _log -b # clear local arrays - unset inputoptions - unset inputoptionsframemd5 - unset middleoptions + unset INPUTOPTIONS + unset INPUTOPTIONSFRAMEMD5 + unset MIDDLEOPTIONS # encoding options - get_codectagstring "${sourcefile}" - get_videostreamcount "${sourcefile}" - get_audiostreamcount "${sourcefile}" - inputoptions+=(-nostdin) - inputoptions+=(-vsync 0) + _get_codectagstring "${SOURCEFILE}" + _get_videostreamcount "${SOURCEFILE}" + _get_audiostreamcount "${SOURCEFILE}" + INPUTOPTIONS+=(-nostdin) + INPUTOPTIONS+=(-vsync 0) if [[ "${VIDEOSTREAMCOUNT}" > 0 ]] ; then - if [[ "${codec_tag_string}" == "mjp2" ]] ; then - inputoptions+=(-vcodec libopenjpeg) + if [[ "${CODEC_TAG_STRING}" == "mjp2" ]] ; then + INPUTOPTIONS+=(-vcodec libopenjpeg) fi - middleoptions+=(-map 0:v) - middleoptions+=(-map 0:a) - if [[ "${jpeg2000mode}" == "Y" ]] ; then - middleoptions+=(-c:v libopenjpeg) - inputoptionsframemd5+=(-vcodec libopenjpeg) - suffix="_j2k" + MIDDLEOPTIONS+=(-map 0:v) + MIDDLEOPTIONS+=(-map 0:a) + if [[ "${JPEG2000MODE}" == "Y" ]] ; then + MIDDLEOPTIONS+=(-c:v libopenjpeg) + INPUTOPTIONSFRAMEMD5+=(-vcodec libopenjpeg) + SUFFIX="_j2k" else - middleoptions+=(-c:v ffv1 -level 3 -g 1) - suffix="_ffv1" + MIDDLEOPTIONS+=(-c:v ffv1 -level 3 -g 1) + SUFFIX="_ffv1" fi - middleoptions+=(-vf setfield=bff) # this is a presumption but much of the uncompressed input is bff but not probably labelled + MIDDLEOPTIONS+=(-vf setfield=bff) # this is a presumption but much of the uncompressed input is bff but not probably labelled fi if [[ "${AUDIOSTREAMCOUNT}" > 0 ]] ; then - middleoptions+=(-c:a copy) + MIDDLEOPTIONS+=(-c:a copy) fi - get_codectagstring "${sourcefile}" - _run mkdir -p "${outputdir}" "${logdir}" - if [ "${codec_tag_string}" == "2vuy" -o "${codec_tag_string}" == "v210" ] ; then - report -dt "${sourcefilename} is ${codec_tag_string}, starting encode" + _get_codectagstring "${SOURCEFILE}" + _run mkdir -p "${OUTPUTDIR}" "${LOGDIR}" + if [ "${CODEC_TAG_STRING}" == "2vuy" -o "${CODEC_TAG_STRING}" == "v210" ] ; then + _report -dt "${SOURCEFILENAME} is ${CODEC_TAG_STRING}, starting encode" _prep_ffmpeg_log - _run_critical ffmpeg ${inputoptions[@]} -i "${sourcefile}" ${middleoptions[@]} "${outputdir}/${sourcefilename%.*}${suffix}.mov" -f framemd5 -an "${logdir}/${sourcefilename%.*}.framemd5" - if [ "${codec_tag_string}" == "2vuy" ] ; then - _run_critical ffmpeg ${inputoptions[@]} -i "${outputdir}/${sourcefilename%.*}${suffix}.mov" -f framemd5 -pix_fmt uyvy422 -an "${logdir}/${sourcefilename%.*}${suffix}.framemd5" + _run_critical ffmpeg ${INPUTOPTIONS[@]} -i "${SOURCEFILE}" ${MIDDLEOPTIONS[@]} "${OUTPUTDIR}/${SOURCEFILENAME%.*}${SUFFIX}.mov" -f framemd5 -an "${LOGDIR}/${SOURCEFILENAME%.*}.framemd5" + if [ "${CODEC_TAG_STRING}" == "2vuy" ] ; then + _run_critical ffmpeg ${INPUTOPTIONS[@]} -i "${OUTPUTDIR}/${SOURCEFILENAME%.*}${SUFFIX}.mov" -f framemd5 -pix_fmt uyvy422 -an "${LOGDIR}/${SOURCEFILENAME%.*}${SUFFIX}.framemd5" else - _run_critical ffmpeg ${inputoptions[@]} ${inputoptionsframemd5[@]} -i "${outputdir}/${sourcefilename%.*}${suffix}.mov" -f framemd5 -an "${logdir}/${sourcefilename%.*}${suffix}.framemd5" + _run_critical ffmpeg ${INPUTOPTIONS[@]} ${INPUTOPTIONSFRAMEMD5[@]} -i "${OUTPUTDIR}/${SOURCEFILENAME%.*}${SUFFIX}.mov" -f framemd5 -an "${LOGDIR}/${SOURCEFILENAME%.*}${SUFFIX}.framemd5" fi - if [ $(grep -v "^#" "${logdir}/${sourcefilename%.*}.framemd5" | md5 -q) = $(grep -v "^#" "${logdir}/${sourcefilename%.*}${suffix}.framemd5" | md5 -q) ] ; then - report -dt "Everything looks safe. Going to delete the original." - _run_critical mediainfo -f --language=raw --output=XML "${sourcefile}" > "${logdir}/${sourcefilename%.*}_mediainfo.xml" - _run_critical rm -f -v "${sourcefile}" + if [ $(grep -v "^#" "${LOGDIR}/${SOURCEFILENAME%.*}.framemd5" | md5 -q) = $(grep -v "^#" "${LOGDIR}/${SOURCEFILENAME%.*}${SUFFIX}.framemd5" | md5 -q) ] ; then + _report -dt "Everything looks safe. Going to delete the original." + _run_critical mediainfo -f --language=raw --output=XML "${SOURCEFILE}" > "${LOGDIR}/${SOURCEFILENAME%.*}_mediainfo.xml" + _run_critical rm -f -v "${SOURCEFILE}" else - report -wt "Not looking safe. Going to keep the original." + _report -wt "Not looking safe. Going to keep the original." fi else - report -wt "${sourcefilename} is not 2vuy or v210 or progressive ffv1, skipping" + _report -wt "${SOURCEFILENAME} is not 2vuy or v210 or progressive ffv1, skipping" continue fi - report -dt done with "${sourcefile}" + _report -dt done with "${SOURCEFILE}" done shift _log -e diff --git a/makemetadata b/makemetadata index b4e8948c..bff72f42 100755 --- a/makemetadata +++ b/makemetadata @@ -1,67 +1,67 @@ #!/bin/bash # make metadata -version="0.2" -scriptdir=$(dirname $(which "${0}")) -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; -dependencies=(ffprobe mediainfo exiftool) +VERSION="0.2" +SCRIPTDIR=$(dirname $(which "${0}")) +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; +DEPENDENCIES=(ffprobe mediainfo exiftool) _initialize_make -usage(){ +_usage(){ echo - echo "$(basename "${0}") ${version}" + echo "$(basename "${0}") ${VERSION}" echo "Produces a set of metadata reports for an archival information package on all files in the objects subdirectory." echo "Usage: $(basename "${0}") [ -h ] package1 [ package2 ... ]" - echo " -h (show usage)" + echo " -h (show _usage)" exit } -[ "${#}" = 0 ] && usage +[ "${#}" = 0 ] && _usage # command-line options to set mediaid and original variables OPTIND=1 -while getopts ":h" opt ; do - case "${opt}" in - h) usage ;; - *) echo "bad option -${OPTARG}" ; usage ;; +while getopts ":h" OPT ; do + case "${OPT}" in + h) _usage ;; + *) echo "bad option -${OPTARG}" ; _usage ;; :) echo "Option -${OPTARG} requires an argument" ; exit 1 ;; esac done shift $(( ${OPTIND} - 1 )) _log -b -outputdir="./metadata/submissionDocumentation/fileMeta" -if [ ! -d "${outputdir}" ] ; then - _run mkdir -p "${outputdir}" +OUTPUTDIR="./metadata/submissionDocumentation/fileMeta" +if [ ! -d "${OUTPUTDIR}" ] ; then + _run mkdir -p "${OUTPUTDIR}" fi while [ "${*}" != "" ] ; do - package_path="${1}" - pwd=$(pwd) - cd "${package_path}" - FILELIST=$(maketemp) + PACKAGE_PATH="${1}" + PWD=$(pwd) + cd "${PACKAGE_PATH}" + FILELIST=$(_maketemp) find "./objects" -type f ! -name ".*" ! -path "*/access/images/*" > "${FILELIST}" - report -dt "Making metadata reports for ${package_path}." - while read file ; do - filenameroot=$(basename "${file}") - parentdir=$(dirname "${file}") - fileoutput="${outputdir}/${parentdir}" - if [ ! -d "${fileoutput}" ] ; then - _run mkdir -p "${fileoutput}" + _report -dt "Making metadata reports for ${PACKAGE_PATH}." + while read FILE ; do + FILENAMEROOT=$(basename "${FILE}") + PARENTDIR=$(dirname "${FILE}") + FILEOUTPUT="${OUTPUTDIR}/${PARENTDIR}" + if [ ! -d "${FILEOUTPUT}" ] ; then + _run mkdir -p "${FILEOUTPUT}" fi - FFPROBEXML="$fileoutput/${filenameroot%.*}_ffprobe.xml" - FFPROBEJSON="$fileoutput/${filenameroot%.*}_ffprobe.json" - MEDIAINFOXML="${fileoutput}/${filenameroot%.*}_mediainfo.xml" - MEDIAINFOTRACE="${fileoutput}/${filenameroot%.*}_mediainfo_trace.txt" - EXIFTOOLXML="${fileoutput}/${filenameroot%.*}_exiftool.xml" - EXIFTOOLTXT="${fileoutput}/${filenameroot%.*}_exiftool.txt" - ffprobe 2> /dev/null "${file}" -show_format -show_streams -show_data -show_error -show_versions -show_chapters -noprivate -of xml="q=1:x=1" > "${FFPROBEXML}" - ffprobe 2> /dev/null "${file}" -show_format -show_streams -show_data -show_error -show_versions -show_chapters -of json > "${FFPROBEJSON}" - mediainfo --language=raw -f --output=XML "${file}" > "${MEDIAINFOXML}" - mediainfo --inform="Details;1" "$file" > "${MEDIAINFOTRACE}" - exiftool -X "${file}" > "${EXIFTOOLXML}" - exiftool "${file}" > "${EXIFTOOLTXT}" + FFPROBEXML="${FILEOUTPUT}/${FILENAMEROOT%.*}_ffprobe.xml" + FFPROBEJSON="${FILEOUTPUT}/${FILENAMEROOT%.*}_ffprobe.json" + MEDIAINFOXML="${FILEOUTPUT}/${FILENAMEROOT%.*}_mediainfo.xml" + MEDIAINFOTRACE="${FILEOUTPUT}/${FILENAMEROOT%.*}_mediainfo_trace.txt" + EXIFTOOLXML="${FILEOUTPUT}/${FILENAMEROOT%.*}_exiftool.xml" + EXIFTOOLTXT="${FILEOUTPUT}/${FILENAMEROOT%.*}_exiftool.txt" + ffprobe 2> /dev/null "${FILE}" -show_format -show_streams -show_data -show_error -show_versions -show_chapters -noprivate -of xml="q=1:x=1" > "${FFPROBEXML}" + ffprobe 2> /dev/null "${FILE}" -show_format -show_streams -show_data -show_error -show_versions -show_chapters -of json > "${FFPROBEJSON}" + mediainfo --language=raw -f --output=XML "${FILE}" > "${MEDIAINFOXML}" + mediainfo --inform="Details;1" "${FILE}" > "${MEDIAINFOTRACE}" + exiftool -X "${FILE}" > "${EXIFTOOLXML}" + exiftool "${FILE}" > "${EXIFTOOLTXT}" done < "${FILELIST}" - cd "${pwd}" + cd "${PWD}" _run rm -r -f "${FILELIST}" shift _log -e diff --git a/makemp3 b/makemp3 index 2db3ab37..d895d330 100755 --- a/makemp3 +++ b/makemp3 @@ -1,93 +1,93 @@ #!/bin/bash # makemp3 -version="1.0" -unset dependencies -dependencies=(ffmpeg normalize) -suffix="" -extension="mp3" -relativepath="access/mp3" +VERSION="1.0" +unset DEPENDENCIES +DEPENDENCIES=(ffmpeg normalize) +SUFFIX="" +EXTENSION="mp3" +RELATIVEPATH="access/mp3" -scriptdir=$(dirname "${0}") -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; +SCRIPTDIR=$(dirname "${0}") +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; -usage(){ +_usage(){ echo - echo "$(basename "${0}") ${version}" - echo "This application will create an mp3 file from a video file or package input with the following options. By default the output will be written to ${outputdir}. You can override this with the -o option." - echo "Dependencies: ${dependencies[@]}" + echo "$(basename "${0}") ${VERSION}" + echo "This application will create an mp3 file from a video file or package input with the following options. By default the output will be written to ${OUTPUTDIR}. You can override this with the -o option." + echo "Dependencies: ${DEPENDENCIES[@]}" echo "Usage: $(basename "${0}") [ -o /directory/to/write/to/ ] fileorpackage1 [ fileorpackage2 ...]" echo " -o directory ( directory to write the resulting file to )" echo " -h ( display this help )" echo exit } -[ "${#}" = 0 ] && usage -check_dependencies "${dependencies[@]}" +[ "${#}" = 0 ] && _usage +_check_dependencies "${DEPENDENCIES[@]}" -cleanup(){ +_cleanup(){ _log -a "Process aborted" exit 1 } -trap cleanup SIGHUP SIGINT SIGTERM +trap _cleanup SIGHUP SIGINT SIGTERM OPTIND=1 -while getopts ":ho:" opt; do - case "${opt}" in - h) usage ;; - o) outputdir="${OPTARG}" - if [ ! -d "${outputdir}" ] ; then - report -wt "The output directory option, ${outputdir}, does not refer to an actual directory. Quitting." +while getopts ":ho:" OPT; do + case "${OPT}" in + h) _usage ;; + o) OUTPUTDIR="${OPTARG}" + if [ ! -d "${OUTPUTDIR}" ] ; then + _report -wt "The output directory option, ${OUTPUTDIR}, does not refer to an actual directory. Quitting." exit 1 fi ;; - *) echo "bad option -${OPTARG}" ; usage ;; + *) echo "bad option -${OPTARG}" ; _usage ;; :) echo "Option -${OPTARG} requires an argument" ; exit 1 ;; esac done shift $(( ${OPTIND} - 1 )) while [ "${*}" != "" ] ; do - input="${1}" - if [ -z "${outputdir}" ] ; then - [ -d "${input}" ] && { outputdir="${input}/objects/${relativepath}" && logdir="${input}/metadata/submissionDocumentation/logs" ;}; - [ -f "${input}" ] && { outputdir=$(dirname "${input}")"/${relativepath}" && logdir="$(dirname "${input}")/${relativepath}/logs" ;}; - [ ! "${outputdir}" ] && { outputdir="${input}/objects/${relativepath}" && logdir="${input}/metadata/submissionDocumentation/logs" ;}; + INPUT="${1}" + if [ -z "${OUTPUTDIR}" ] ; then + [ -d "${INPUT}" ] && { OUTPUTDIR="${INPUT}/objects/${RELATIVEPATH}" && LOGDIR="${INPUT}/metadata/submissionDocumentation/logs" ;}; + [ -f "${INPUT}" ] && { OUTPUTDIR=$(dirname "${INPUT}")"/${RELATIVEPATH}" && LOGDIR="$(dirname "${INPUT}")/${RELATIVEPATH}/logs" ;}; + [ ! "${OUTPUTDIR}" ] && { OUTPUTDIR="${INPUT}/objects/${RELATIVEPATH}" && LOGDIR="${INPUT}/metadata/submissionDocumentation/logs" ;}; else - logdir="${outputdir}/logs" + LOGDIR="${OUTPUTDIR}/logs" fi - _find_input "${input}" + _find_input "${INPUT}" - filename=$(basename "${sourcefile}") - mediaid=$(basename "${input}" | cut -d. -f1) + FILENAME=$(basename "${SOURCEFILE}") + MEDIAID=$(basename "${INPUT}" | cut -d. -f1) _log -b _set_up_output - unset inputoptions - unset middleoptions - inputoptions+=(-nostdin) - middleoptions+=(-map 0:a:0) - middleoptions+=(-ac 2) - middleoptions+=(-r:a 44100) - middleoptions+=(-sample_fmt s16p) - get_audio_mapping "${sourcefile}" - middleoptions+=(${audiomapping_ffmpeg[@]}) + unset INPUTOPTIONS + unset MIDDLEOPTIONS + INPUTOPTIONS+=(-nostdin) + MIDDLEOPTIONS+=(-map 0:a:0) + MIDDLEOPTIONS+=(-ac 2) + MIDDLEOPTIONS+=(-r:a 44100) + MIDDLEOPTIONS+=(-sample_fmt s16p) + _get_audio_mapping "${SOURCEFILE}" + MIDDLEOPTIONS+=("${AUDIOMAPPING_FFMPEG[@]}") - if [ "${logdir}" != "" ] ; then - mkdir -p "${logdir}" - export FFREPORT="file=${logdir}/%p_%t_$(basename "${0}")_${version}.txt" - inputoptions+=(-v warning -stats) + if [ "${LOGDIR}" != "" ] ; then + mkdir -p "${LOGDIR}" + export FFREPORT="file=${LOGDIR}/%p_%t_$(basename "${0}")_${VERSION}.txt" + INPUTOPTIONS+=(-v warning -stats) fi - report -dt "Working on $(basename "${output}")." - report -dt "Running: ffmpeg ${inputoptions[@]} -i \"${sourcefile}\" ${middleoptions[@]} \"${output}\"" - ffmpeg ${inputoptions[@]} -i "${sourcefile}" ${middleoptions[@]} "${output}" - report -dt "Adjusting highest audio peak to full scale..." - normalize --peak -v "${output}" + _report -dt "Working on $(basename "${OUTPUT}")." + _report -dt "Running: ffmpeg ${INPUTOPTIONS[@]} -i \"${SOURCEFILE}\" ${MIDDLEOPTIONS[@]} \"${OUTPUT}\"" + ffmpeg "${INPUTOPTIONS[@]}" -i "${SOURCEFILE}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}" + _report -dt "Adjusting highest audio peak to full scale..." + normalize --peak -v "${OUTPUT}" echo - report -dt "$(basename ${output}) is done." + _report -dt "$(basename ${OUTPUT}) is done." shift _log -e done diff --git a/makepdf b/makepdf index e516c677..053a21b1 100755 --- a/makepdf +++ b/makepdf @@ -1,46 +1,46 @@ #!/bin/bash # makepdf, makes a pdf from an image series -version="1.0" -scriptdir=$(dirname $(which "${0}")) -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; -dependencies=(ffmpeg convert pdfjoin tesseract) +VERSION="1.0" +SCRIPTDIR=$(dirname $(which "${0}")) +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; +DEPENDENCIES=(ffmpeg convert pdfjoin tesseract) _initialize_make fix_tif_name(){ local tif="${1}" - local tifname=$(basename "${tif}") - local tifdir=$(dirname "${tif}") + local tifname=$(basename "${TIF}") + local tifdir=$(dirname "${TIF}") local basename=$(echo "${tifname}" | cut -d_ -f1 | cut -d. -f2) local pageno=$(echo "${tifname}" | cut -d_ -f2 | cut -d. -f1) - local extension=$(echo "${tifname}" | cut -d_ -f2 | cut -d. -f2) + local EXTENSION=$(echo "${tifname}" | cut -d_ -f2 | cut -d. -f2) local pageno=$(echo "0000${pageno}" | tail -c 4 | head -c 3) - report -dt "Renaming to fit image sequence naming pattern." - local old_tif_name="${tif}" - new_tif_name="${tifdir}/${basename}_${pageno}.${extension}" - mv -v -n "${old_tif_name}" "${new_tif_name}" + _report -dt "Renaming to fit image sequence naming pattern." + local old_tif_name="${TIF}" + NEW_TIF_NAME="${tifdir}/${basename}_${pageno}.${EXTENSION}" + mv -v -n "${old_tif_name}" "${NEW_TIF_NAME}" } check_tif_name(){ local tif="${1}" - local tifname=$(basename "${tif}") - local tifdir=$(dirname "${tif}") + local tifname=$(basename "${TIF}") + local tifdir=$(dirname "${TIF}") local basename=$(echo "${tifname}" | cut -d_ -f2 | cut -d. -f2) local pageno=$(echo "${tifname}" | cut -d_ -f2 | cut -d. -f1) - local extension=$(echo "${tifname}" | cut -d_ -f2 | cut -d. -f1) + local EXTENSION=$(echo "${tifname}" | cut -d_ -f2 | cut -d. -f1) local pageno=$(echo "0000${pageno}" | tail -c 4 | head -c 3) - if [ "$extension" = "tif" ] && [ $(echo $pageno | awk '{print length()}') = "3" ] ; then + if [ "$EXTENSION" = "TIF" ] && [ $(echo $pageno | awk '{print length()}') = "3" ] ; then continue else - fix_tif_name "${tif}" + fix_tif_name "${TIF}" fi } -usage(){ +_usage(){ echo - echo "$(basename "${0}") ${version}" + echo "$(basename "${0}") ${VERSION}" echo "This application will create a small pdf file (suitable for sharing online) from a collection of image file or package input with the following options." - echo "Dependencies: ${dependencies[@]}" - echo "Usage: $(basename $0) [ -d /path/to/deliver/to/ ] fileorpackage1 [ fileorpackage2 ...]" + echo "Dependencies: ${DEPENDENCIES[@]}" + echo "Usage: $(basename ${0}) [ -d /path/to/deliver/to/ ] fileorpackage1 [ fileorpackage2 ...]" echo " -d directory ( directory to deliver the resulting file to )" echo " -o directory ( directory to write the resulting file to )" echo " -n (dry-run mode, show the commands that would be run but don't do anything)" @@ -50,76 +50,76 @@ usage(){ echo exit } -[ "${#}" = 0 ] && usage +[ "${#}" = 0 ] && _usage # command-line options to set mediaid and original variables OPTIND=1 -while getopts ":o:d:e:E:nh" opt ; do - case "${opt}" in - o) outputdir_forced="$OPTARG" && _check_outputdir_forced ;; - d) deliverdir="$OPTARG" && check_deliverdir ;; - e) emailaddress_delivery="$OPTARG" ;; - E) emailaddress_outcome="$OPTARG" ;; +while getopts ":o:d:e:E:nh" OPT ; do + case "${OPT}" in + o) OUTPUTDIR_FORCED="${OPTARG}" && _check_outputdir_forced ;; + d) DELIVERDIR="${OPTARG}" && _check_deliverdir ;; + e) EMAILADDRESS_DELIVERY="${OPTARG}" ;; + E) EMAILADDRESS_OUTCOME="${OPTARG}" ;; n) DRYRUN=true;; - h) usage ;; - *) echo "bad option -$OPTARG" ; usage ;; - :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; + h) _usage ;; + *) echo "bad option -${OPTARG}" ; _usage ;; + :) echo "Option -${OPTARG} requires an argument" ; exit 1 ;; esac done shift $(( ${OPTIND} - 1 )) -[ "${emailaddress_outcome}" ] && check_emailaddress "${emailaddress_outcome}" -[ "${emailaddress_delivery}" ] && check_emailaddress "${emailaddress_delivery}" +[ "${EMAILADDRESS_OUTCOME}" ] && check_emailaddress "${EMAILADDRESS_OUTCOME}" +[ "${EMAILADDRESS_DELIVERY}" ] && check_emailaddress "${EMAILADDRESS_DELIVERY}" while [ "${*}" != "" ] ; do # get context about the input - input="${1}" + INPUT="${1}" shift - if [ -z "${outputdir_forced}" ] ; then - [ -d "${input}" ] && { outputdir="${input}/objects/access/pdf_1" && logdir="${input}/metadata/submissionDocumentation/logs" ;}; - [ -f "${input}" ] && { outputdir=$(dirname "${input}")"/access/pdf_1" && logdir="$(dirname "${input}")/access/logs" ;}; - [ ! "${outputdir}" ] && { outputdir="${input}/objects/access/pdf_1" && logdir="${input}/metadata/submissionDocumentation/logs" ;}; + if [ -z "${OUTPUTDIR_FORCED}" ] ; then + [ -d "${INPUT}" ] && { OUTPUTDIR="${INPUT}/objects/access/pdf_1" && LOGDIR="${INPUT}/metadata/submissionDocumentation/logs" ;}; + [ -f "${INPUT}" ] && { OUTPUTDIR=$(dirname "${INPUT}")"/access/pdf_1" && LOGDIR="$(dirname "${INPUT}")/access/logs" ;}; + [ ! "${OUTPUTDIR}" ] && { OUTPUTDIR="${INPUT}/objects/access/pdf_1" && LOGDIR="${INPUT}/metadata/submissionDocumentation/logs" ;}; else - outputdir="${outputdir_forced}" - logdir="${outputdir}/logs" + OUTPUTDIR="${OUTPUTDIR_FORCED}" + LOGDIR="${OUTPUTDIR}/logs" fi - _run mkdir -p "${logdir}" - exec > >(tee "${logdir}/$(basename "${0}")_$(get_iso8601_c)_$(basename $0)_${version}.txt") + _run mkdir -p "${LOGDIR}" + exec > >(tee "${LOGDIR}/$(basename "${0}")_$(_get_iso8601_c)_$(basename ${0})_${VERSION}.txt") exec 2>&1 - #_find_input "${input}" - if [ -d "${input}/objects" ] ; then - sourcedir="${input}/objects" + #_find_input "${INPUT}" + if [ -d "${INPUT}/objects" ] ; then + SOURCEDIR="${INPUT}/objects" else - report -wt "No source objects folder" + _report -wt "No source objects folder" exit 1 fi - mediaid=$(basename "${input}" | cut -d. -f1) + MEDIAID=$(basename "${INPUT}" | cut -d. -f1) # set up output _log -b - output="${outputdir}/${mediaid%.*}.pdf" - [ -s "${output}" ] && { report -wt "WARNING ${output} already exists, skipping process" ; shift ; continue ;}; - _run mkdir -p "${outputdir}" + OUTPUT="${OUTPUTDIR}/${MEDIAID%.*}.pdf" + [ -s "${OUTPUT}" ] && { _report -wt "WARNING ${OUTPUT} already exists, skipping process" ; shift ; continue ;}; + _run mkdir -p "${OUTPUTDIR}" - tmp_makepdf_dir="${input}/tmp" - tmp_png_dir="${tmp_makepdf_dir}/pngs" - tmp_clean_dir="${tmp_makepdf_dir}/pngs_cleaned" - _run mkdir -p "${tmp_makepdf_dir}" "${tmp_png_dir}" "${tmp_clean_dir}" + TMP_MAKEPDF_DIR="${INPUT}/tmp" + TMP_PNG_DIR="${TMP_MAKEPDF_DIR}/pngs" + TMP_CLEAN_DIR="${TMP_MAKEPDF_DIR}/pngs_cleaned" + _run mkdir -p "${TMP_MAKEPDF_DIR}" "${TMP_PNG_DIR}" "${TMP_CLEAN_DIR}" - for tif in `find "$sourcedir" -maxdepth 1 -mindepth 1 -iname "*.tif" -type f` ; do - check_tif_name "${tif}" - if [ "${new_tif_name}" ] ; then - tif="${new_tif_name}" + for TIF in `find "${SOURCEDIR}" -maxdepth 1 -mindepth 1 -iname "*.tif" -type f` ; do + check_tif_name "${TIF}" + if [ "${NEW_TIF_NAME}" ] ; then + TIF="${NEW_TIF_NAME}" fi - ffmpeg -i "${tif}" -pix_fmt gray "${tmp_png_dir}/$(basename "${tif%.*}").png" - convert "${tmp_png_dir}/$(basename "${tif%.*}").png" -level 10%,90%,1 -blur 2 +dither -resize 2550x3300 -monochrome -flatten +repage -define png:bit-depth=8 -define png:color-type=0 "${tmp_clean_dir}/$(basename "${tif%.*}").png" - tesseract "${tmp_clean_dir}/$(basename "${tif%.*}").png" "${tmp_clean_dir}/$(basename "${tif%.*}")" -l eng -psm 4 pdf "${scriptdir}/tesseract.conf" + ffmpeg -i "${TIF}" -pix_fmt gray "${TMP_PNG_DIR}/$(basename "${TIF%.*}").png" + convert "${TMP_PNG_DIR}/$(basename "${TIF%.*}").png" -level 10%,90%,1 -blur 2 +dither -resize 2550x3300 -monochrome -flatten +repage -define png:bit-depth=8 -define png:color-type=0 "${TMP_CLEAN_DIR}/$(basename "${TIF%.*}").png" + tesseract "${TMP_CLEAN_DIR}/$(basename "${TIF%.*}").png" "${TMP_CLEAN_DIR}/$(basename "${TIF%.*}")" -l eng -psm 4 pdf "${SCRIPTDIR}/tesseract.conf" done - pdfjoin --fitpaper 'false' --rotateoversize 'false' --paper letter $(find "${tmp_clean_dir}" -name "*.pdf" | sort | xargs) --outfile "${outputdir}/${mediaid}.pdf" + pdfjoin --fitpaper 'false' --rotateoversize 'false' --paper letter $(find "${TMP_CLEAN_DIR}" -name "*.pdf" | sort | xargs) --outfile "${OUTPUTDIR}/${MEDIAID}.pdf" - #if [ -d "${tmp_makepdf_dir}" ] ; then - # _run rm -rvf "${tmp_makepdf_dir}" + #if [ -d "${TMP_MAKEPDF_DIR}" ] ; then + # _run rm -rvf "${TMP_MAKEPDF_DIR}" #fi _summarize_make _deliver_output "${MAKEYOUTUBE_DELIVERY_EMAIL_TO}" diff --git a/makepodcast b/makepodcast index 15076d15..184f84f0 100755 --- a/makepodcast +++ b/makepodcast @@ -1,20 +1,20 @@ #!/bin/bash # makepodcast, makes a file appropriate for podcasting -version="1.0" -scriptdir=$(dirname $(which "${0}")) -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; -dependencies=(ffmpeg ffprobe) +VERSION="1.0" +SCRIPTDIR=$(dirname $(which "${0}")) +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; +DEPENDENCIES=(ffmpeg ffprobe) _initialize_make -suffix="_podcast" -extension="mov" -relativepath="access/podcast" +SUFFIX="_podcast" +EXTENSION="mov" +RELATIVEPATH="access/podcast" -usage(){ +_usage(){ echo - echo "$(basename "${0}") ${version}" + echo "$(basename "${0}") ${VERSION}" echo "This application will create a QuickTime file suitable for podcasting from a video file or package input with the following options." - echo "Dependencies: ${dependencies[@]}" - echo "Usage: $(basename $0) [ -d /path/to/deliver/to/ ] fileorpackage1 [ fileorpackage2 ...]" + echo "Dependencies: ${DEPENDENCIES[@]}" + echo "Usage: $(basename ${0}) [ -d /path/to/deliver/to/ ] fileorpackage1 [ fileorpackage2 ...]" echo " -d directory ( directory to deliver the resulting file to )" echo " -o directory ( directory to write the resulting file to )" echo " -n (dry-run mode, show the commands that would be run but don't do anything)" @@ -24,76 +24,76 @@ usage(){ echo exit } -[ "${#}" = 0 ] && usage +[ "${#}" = 0 ] && _usage # command-line options to set mediaid and original variables OPTIND=1 -while getopts ":o:d:e:E:nh" opt ; do - case "${opt}" in - o) outputdir_forced="$OPTARG" && _check_outputdir_forced ;; - d) deliverdir="$OPTARG" && check_deliverdir ;; - e) emailaddress_delivery="$OPTARG" && check_emailaddress "${emailaddress_delivery}" ;; - E) emailaddress_outcome="$OPTARG" && check_emailaddress "${emailaddress_outcome}" ;; +while getopts ":o:d:e:E:nh" OPT ; do + case "${OPT}" in + o) OUTPUTDIR_FORCED="${OPTARG}" && _check_outputdir_forced ;; + d) DELIVERDIR="${OPTARG}" && _check_deliverdir ;; + e) EMAILADDRESS_DELIVERY="${OPTARG}" && check_emailaddress "${EMAILADDRESS_DELIVERY}" ;; + E) EMAILADDRESS_OUTCOME="${OPTARG}" && check_emailaddress "${EMAILADDRESS_OUTCOME}" ;; n) DRYRUN=true;; - h) usage ;; - *) echo "bad option -$OPTARG" ; usage ;; - :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; + h) _usage ;; + *) echo "bad option -${OPTARG}" ; _usage ;; + :) echo "Option -${OPTARG} requires an argument" ; exit 1 ;; esac done shift $(( ${OPTIND} - 1 )) while [ "${*}" != "" ] ; do # get context about the input - input="${1}" + INPUT="${1}" shift - if [ -z "${outputdir_forced}" ] ; then - [ -d "${input}" ] && { outputdir="$input/objects/${relativepath}" && logdir="${input}/metadata/submissionDocumentation/logs" ;}; - [ -f "${input}" ] && { outputdir=$(dirname "${input}")"/${relativepath}" && logdir="$(dirname "${input}")/${relativepath}/logs" ;}; - [ ! "${outputdir}" ] && { outputdir="${input}/objects/${relativepath}" && logdir="${input}/metadata/submissionDocumentation/logs" ;}; + if [ -z "${OUTPUTDIR_FORCED}" ] ; then + [ -d "${INPUT}" ] && { OUTPUTDIR="$INPUT/objects/${RELATIVEPATH}" && LOGDIR="${INPUT}/metadata/submissionDocumentation/logs" ;}; + [ -f "${INPUT}" ] && { OUTPUTDIR=$(dirname "${INPUT}")"/${RELATIVEPATH}" && LOGDIR="$(dirname "${INPUT}")/${RELATIVEPATH}/logs" ;}; + [ ! "${OUTPUTDIR}" ] && { OUTPUTDIR="${INPUT}/objects/${RELATIVEPATH}" && LOGDIR="${INPUT}/metadata/submissionDocumentation/logs" ;}; else - outputdir="${outputdir_forced}" - logdir="${outputdir}/logs" + OUTPUTDIR="${OUTPUTDIR_FORCED}" + LOGDIR="${OUTPUTDIR}/logs" fi - _find_input "${input}" - mediaid=$(basename "${input}" | cut -d. -f1) + _find_input "${INPUT}" + MEDIAID=$(basename "${INPUT}" | cut -d. -f1) _set_up_output # clear local arrays - unset inputoptions - unset middleoptions + unset INPUTOPTIONS + unset MIDDLEOPTIONS # encoding options - get_codectagstring "${sourcefile}" - get_videostreamcount "${sourcefile}" - get_audiostreamcount "${sourcefile}" - inputoptions+=(-nostdin) + _get_codectagstring "${SOURCEFILE}" + _get_videostreamcount "${SOURCEFILE}" + _get_audiostreamcount "${SOURCEFILE}" + INPUTOPTIONS+=(-nostdin) if [[ "${VIDEOSTREAMCOUNT}" > 0 ]] ; then - if [[ "${codec_tag_string}" == "mjp2" ]] ; then - inputoptions+=(-vcodec libopenjpeg) + if [[ "${CODEC_TAG_STRING}" == "mjp2" ]] ; then + INPUTOPTIONS+=(-vcodec libopenjpeg) fi - middleoptions+=(-movflags faststart) - middleoptions+=(-pix_fmt yuv420p) - middleoptions+=(-c:v libx264) - middleoptions+=(-b:v 1500k) - middleoptions+=(-maxrate:v 3000k) - middleoptions+=(-minrate:v 375k) - middleoptions+=(-bufsize:v 6000k) - middleoptions+=(-vf "yadif,scale=640:trunc(ow/dar/2)*2:interl=1") + MIDDLEOPTIONS+=(-movflags faststart) + MIDDLEOPTIONS+=(-pix_fmt yuv420p) + MIDDLEOPTIONS+=(-c:v libx264) + MIDDLEOPTIONS+=(-b:v 1500k) + MIDDLEOPTIONS+=(-maxrate:v 3000k) + MIDDLEOPTIONS+=(-minrate:v 375k) + MIDDLEOPTIONS+=(-bufsize:v 6000k) + MIDDLEOPTIONS+=(-vf "yadif,scale=640:trunc(ow/dar/2)*2:interl=1") fi if [[ "${AUDIOSTREAMCOUNT}" > 0 ]] ; then - middleoptions+=(-c:a aac -strict -2) - middleoptions+=(-b:a 96k) - get_audio_mapping "${sourcefile}" - middleoptions+=(${audiomapping_ffmpeg[@]}) + MIDDLEOPTIONS+=(-c:a aac -strict -2) + MIDDLEOPTIONS+=(-b:a 96k) + _get_audio_mapping "${SOURCEFILE}" + MIDDLEOPTIONS+=("${AUDIOMAPPING_FFMPEG[@]}") fi _prep_ffmpeg_log - if [ "${concatsource}" != "" ] ; then - ffmpeginput="${concatsource}" + if [ "${CONCATSOURCE}" != "" ] ; then + FFMPEGINPUT="${CONCATSOURCE}" else - ffmpeginput="${sourcefile}" + FFMPEGINPUT="${SOURCEFILE}" fi - _run_critical ffmpeg ${inputoptions[@]} -i "${ffmpeginput}" ${middleoptions[@]} "${output}" + _run_critical ffmpeg "${INPUTOPTIONS[@]}" -i "${FFMPEGINPUT}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}" echo _summarize_make _deliver_output "${MAKEYOUTUBE_DELIVERY_EMAIL_TO}" diff --git a/makeprores b/makeprores index f56c5785..9b431844 100755 --- a/makeprores +++ b/makeprores @@ -1,22 +1,22 @@ #!/bin/bash # makeprores, makes a file appropriate for keeping editors happy -version="1.0" -scriptdir=$(dirname $(which "${0}")) -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; -dependencies=(ffmpeg) +VERSION="1.0" +SCRIPTDIR=$(dirname $(which "${0}")) +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; +DEPENDENCIES=(ffmpeg) _initialize_make -suffix="" -extension="mov" -relativepath="access/prores" +SUFFIX="" +EXTENSION="mov" +RELATIVEPATH="access/prores" -outputdir="$HOME/Desktop/$(basename $0)" # default output directory, override with -o +OUTPUTDIR="${HOME}/Desktop/$(basename ${0})" # default output directory, override with -o -usage(){ +_usage(){ echo - echo "$(basename "${0}") ${version}" - echo "This application will create a prores/quicktime file (suitable for editing) from a video file or package input with the following options. By default the output will be written to ${outputdir}. You can override this with the -o option." - echo "Dependencies: ${dependencies[@]}" - echo "Usage: $(basename $0) [ -o /directory/to/write/to/ ] fileorpackage1 [ fileorpackage2 ...]" + echo "$(basename "${0}") ${VERSION}" + echo "This application will create a prores/quicktime file (suitable for editing) from a video file or package input with the following options. By default the output will be written to ${OUTPUTDIR}. You can override this with the -o option." + echo "Dependencies: ${DEPENDENCIES[@]}" + echo "Usage: $(basename ${0}) [ -o /directory/to/write/to/ ] fileorpackage1 [ fileorpackage2 ...]" echo " -d directory ( directory to deliver the resulting file to )" echo " -o directory ( directory to write the resulting file to )" echo " -n (dry-run mode, show the commands that would be run but don't do anything)" @@ -26,86 +26,86 @@ usage(){ echo exit } -[ "${#}" = 0 ] && usage +[ "${#}" = 0 ] && _usage # command-line options to set mediaid and original variables OPTIND=1 -while getopts ":o:d:e:E:nh" opt ; do - case "${opt}" in - o) outputdir_forced="$OPTARG" && _check_outputdir_forced ;; - d) deliverdir="$OPTARG" && check_deliverdir ;; - e) emailaddress_delivery="$OPTARG" && check_emailaddress "${emailaddress_delivery}" ;; - E) emailaddress_outcome="$OPTARG" && check_emailaddress "${emailaddress_outcome}" ;; +while getopts ":o:d:e:E:nh" OPT ; do + case "${OPT}" in + o) OUTPUTDIR_FORCED="${OPTARG}" && _check_outputdir_forced ;; + d) DELIVERDIR="${OPTARG}" && _check_deliverdir ;; + e) EMAILADDRESS_DELIVERY="${OPTARG}" && check_emailaddress "${EMAILADDRESS_DELIVERY}" ;; + E) EMAILADDRESS_OUTCOME="${OPTARG}" && check_emailaddress "${EMAILADDRESS_OUTCOME}" ;; n) DRYRUN=true;; - h) usage ;; - *) echo "bad option -$OPTARG" ; usage ;; - :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; + h) _usage ;; + *) echo "bad option -${OPTARG}" ; _usage ;; + :) echo "Option -${OPTARG} requires an argument" ; exit 1 ;; esac done shift $(( ${OPTIND} - 1 )) while [ "${*}" != "" ] ; do # get context about the input - input="${1}" + INPUT="${1}" shift - if [ -z "${outputdir_forced}" ] ; then - [ -d "${input}" ] && { outputdir="${input}/objects/${relativepath}" && logdir="${input}/metadata/submissionDocumentation/logs" ;}; - [ -f "${input}" ] && { outputdir=$(dirname "${input}")"/${relativepath}" && logdir="$(dirname "${input}")/${relativepath}/logs" ;}; - [ ! "${outputdir}" ] && { outputdir="${input}/objects/${relativepath}" && logdir="${input}/metadata/submissionDocumentation/logs" ;}; + if [ -z "${OUTPUTDIR_FORCED}" ] ; then + [ -d "${INPUT}" ] && { OUTPUTDIR="${INPUT}/objects/${RELATIVEPATH}" && LOGDIR="${INPUT}/metadata/submissionDocumentation/logs" ;}; + [ -f "${INPUT}" ] && { OUTPUTDIR=$(dirname "${INPUT}")"/${RELATIVEPATH}" && LOGDIR="$(dirname "${INPUT}")/${RELATIVEPATH}/logs" ;}; + [ ! "${OUTPUTDIR}" ] && { OUTPUTDIR="${INPUT}/objects/${RELATIVEPATH}" && LOGDIR="${INPUT}/metadata/submissionDocumentation/logs" ;}; else - outputdir="${outputdir_forced}" - logdir="${outputdir}/logs" + OUTPUTDIR="${OUTPUTDIR_FORCED}" + LOGDIR="${OUTPUTDIR}/logs" fi - _find_input "${input}" - mediaid=$(basename "${input}" | cut -d. -f1) + _find_input "${INPUT}" + MEDIAID=$(basename "${INPUT}" | cut -d. -f1) _set_up_output # clear local arrays - unset inputoptions - unset middleoptions + unset INPUTOPTIONS + unset MIDDLEOPTIONS # encoding options - get_codectagstring "${sourcefile}" - get_videostreamcount "${sourcefile}" - get_audiostreamcount "${sourcefile}" - inputoptions+=(-vsync 0) - inputoptions+=(-nostdin) + _get_codectagstring "${SOURCEFILE}" + _get_videostreamcount "${SOURCEFILE}" + _get_audiostreamcount "${SOURCEFILE}" + INPUTOPTIONS+=(-vsync 0) + INPUTOPTIONS+=(-nostdin) if [[ "${VIDEOSTREAMCOUNT}" > 0 ]] ; then - if [[ "${codec_tag_string}" == "mjp2" ]] ; then - inputoptions+=(-vcodec libopenjpeg) + if [[ "${CODEC_TAG_STRING}" == "mjp2" ]] ; then + INPUTOPTIONS+=(-vcodec libopenjpeg) fi - middleoptions+=(-map 0:v) - middleoptions+=(-c:v prores) + MIDDLEOPTIONS+=(-map 0:v) + MIDDLEOPTIONS+=(-c:v prores) fi if [[ "${AUDIOSTREAMCOUNT}" > 0 ]] ; then - middleoptions+=(-map 0:a) - middleoptions+=(-c:a pcm_s16le) + MIDDLEOPTIONS+=(-map 0:a) + MIDDLEOPTIONS+=(-c:a pcm_s16le) fi # set in and out times if used - ingestlog="${logdir}/capture.log" - if [[ -f "${ingestlog}" && "${isobject}" = "Y" ]] ; then - intime=$(_readingestlog "intime") - outtime=$(_readingestlog "outtime") - if [[ "${intime}" ]] ; then - report -dt "ATTENTION: Transcoding will use intime (${intime}) during transcoding." - inputoptions+=(-seek_timestamp 1) - middleoptions+=(-ss "${intime}") + INGESTLOG="${LOGDIR}/capture.log" + if [[ -f "${INGESTLOG}" && "${ISOBJECT}" = "Y" ]] ; then + INTIME=$(_readingestlog "intime") + OUTTIME=$(_readingestlog "outtime") + if [[ "${INTIME}" ]] ; then + _report -dt "ATTENTION: Transcoding will use intime (${INTIME}) during transcoding." + INPUTOPTIONS+=(-seek_timestamp 1) + MIDDLEOPTIONS+=(-ss "${INTIME}") fi - if [[ "${outtime}" ]] ; then - report -dt "ATTENTION: Transcoding will use outtime (${outtime}) during transcoding." - middleoptions+=(-to "${outtime}") + if [[ "${OUTTIME}" ]] ; then + _report -dt "ATTENTION: Transcoding will use outtime (${OUTTIME}) during transcoding." + MIDDLEOPTIONS+=(-to "${OUTTIME}") fi fi _prep_ffmpeg_log - if [ "${concatsource}" != "" ] ; then - ffmpeginput="${concatsource}" + if [ "${CONCATSOURCE}" != "" ] ; then + FFMPEGINPUT="${CONCATSOURCE}" else - ffmpeginput="${sourcefile}" + FFMPEGINPUT="${SOURCEFILE}" fi - _run_critical ffmpeg ${inputoptions[@]} -i "${ffmpeginput}" ${middleoptions[@]} "${output}" + _run_critical ffmpeg "${INPUTOPTIONS[@]}" -i "${FFMPEGINPUT}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}" echo _summarize_make _deliver_output diff --git a/makeqctoolsreport b/makeqctoolsreport index 90fbb6dd..8030e7c0 100755 --- a/makeqctoolsreport +++ b/makeqctoolsreport @@ -3,10 +3,10 @@ # this bash script accepts one or many video file inputs and produces # sidecar QCTools xml.gz report file for each input -get_videostreamcount(){ +_get_videostreamcount(){ VIDEOSTREAMCOUNT=$(ffprobe "${1}" -select_streams v -show_entries stream=index -of flat 2>/dev/null | awk 'END { print NR }') } -get_audiostreamcount(){ +_get_audiostreamcount(){ AUDIOSTREAMCOUNT=$(ffprobe "${1}" -select_streams a -show_entries stream=index -of flat 2>/dev/null | awk 'END { print NR }') } @@ -16,8 +16,8 @@ while [ "${*}" != "" ] ; do unset moviefilteroutput unset ebur128filters file="${1}" - get_videostreamcount "${file}" - get_audiostreamcount "${file}" + _get_videostreamcount "${file}" + _get_audiostreamcount "${file}" if [[ "${VIDEOSTREAMCOUNT}" > 0 ]] ; then moviefiltermap=":s=v" moviefilteroutput="[v0]" diff --git a/makeyoutube b/makeyoutube index 1febf81d..45838c96 100755 --- a/makeyoutube +++ b/makeyoutube @@ -1,21 +1,21 @@ #!/bin/bash # makeyoutube, makes a file appropriate for uploading to youtube -version="1.0" -scriptdir=$(dirname $(which "${0}")) -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; -dependencies=(ffmpeg ffprobe) +VERSION="1.0" +SCRIPTDIR=$(dirname $(which "${0}")) +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; +DEPENDENCIES=(ffmpeg ffprobe) _initialize_make -suffix="" -extension="mp4" -relativepath="access/youtube_up" +SUFFIX="" +EXTENSION="mp4" +RELATIVEPATH="access/youtube_up" unset YOUTUBEUPLOAD -usage(){ +_usage(){ echo - echo "$(basename "${0}") ${version}" + echo "$(basename "${0}") ${VERSION}" echo "This application will create a high quality h264 file (suitable for uploading to YouTube) from a video file or package input with the following options." - echo "Dependencies: ${dependencies[@]}" - echo "Usage: $(basename $0) [ -d /path/to/deliver/to/ ] fileorpackage1 [ fileorpackage2 ...]" + echo "Dependencies: ${DEPENDENCIES[@]}" + echo "Usage: $(basename ${0}) [ -d /path/to/deliver/to/ ] fileorpackage1 [ fileorpackage2 ...]" echo " -l (only use the left channel of the first audio track)" echo " -r (only use the right channel of the first audio track)" echo " -d directory ( directory to deliver the resulting file to )" @@ -28,120 +28,120 @@ usage(){ echo exit } -[ "${#}" = 0 ] && usage +[ "${#}" = 0 ] && _usage # command-line options to set mediaid and original variables OPTIND=1 -while getopts ":lrv:o:d:e:E:nhY" opt ; do - case "${opt}" in - l) audiomap="L";; - r) audiomap="R";; +while getopts ":lrv:o:d:e:E:nhY" OPT ; do + case "${OPT}" in + l) AUDIOMAP="L";; + r) AUDIOMAP="R";; v) VOLADJUST="${OPTARG}";; - o) outputdir_forced="$OPTARG" && _check_outputdir_forced ;; - d) deliverdir="$OPTARG" && check_deliverdir ;; - e) emailaddress_delivery="$OPTARG" && check_emailaddress "${emailaddress_delivery}" ;; - E) emailaddress_outcome="$OPTARG" && check_emailaddress "${emailaddress_outcome}" ;; + o) OUTPUTDIR_FORCED="${OPTARG}" && _check_outputdir_forced ;; + d) DELIVERDIR="${OPTARG}" && _check_deliverdir ;; + e) EMAILADDRESS_DELIVERY="${OPTARG}" && check_emailaddress "${EMAILADDRESS_DELIVERY}" ;; + E) EMAILADDRESS_OUTCOME="${OPTARG}" && check_emailaddress "${EMAILADDRESS_OUTCOME}" ;; n) DRYRUN=true;; Y) YOUTUBEUPLOAD="Y";; - h) usage ;; - *) echo "bad option -$OPTARG" ; usage ;; - :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; + h) _usage ;; + *) echo "bad option -${OPTARG}" ; _usage ;; + :) echo "Option -${OPTARG} requires an argument" ; exit 1 ;; esac done shift $(( ${OPTIND} - 1 )) while [ "${*}" != "" ] ; do # get context about the input - input="${1}" + INPUT="${1}" shift - if [ -z "${outputdir_forced}" ] ; then - [ -d "${input}" ] && { outputdir="${input}/objects/${relativepath}" && logdir="${input}/metadata/submissionDocumentation/logs" ;}; - [ -f "${input}" ] && { outputdir=$(dirname "${input}")"/${relativepath}" && logdir="$(dirname "${input}")/${relativepath}/logs" ;}; - [ ! "${outputdir}" ] && { outputdir="${input}/objects/${relativepath}" && logdir="${input}/metadata/submissionDocumentation/logs" ;}; + if [ -z "${OUTPUTDIR_FORCED}" ] ; then + [ -d "${INPUT}" ] && { OUTPUTDIR="${INPUT}/objects/${RELATIVEPATH}" && LOGDIR="${INPUT}/metadata/submissionDocumentation/logs" ;}; + [ -f "${INPUT}" ] && { OUTPUTDIR=$(dirname "${INPUT}")"/${RELATIVEPATH}" && LOGDIR="$(dirname "${INPUT}")/${RELATIVEPATH}/logs" ;}; + [ ! "${OUTPUTDIR}" ] && { OUTPUTDIR="${INPUT}/objects/${RELATIVEPATH}" && LOGDIR="${INPUT}/metadata/submissionDocumentation/logs" ;}; else - outputdir="${outputdir_forced}" - logdir="${outputdir}/logs" + OUTPUTDIR="${OUTPUTDIR_FORCED}" + LOGDIR="${OUTPUTDIR}/logs" fi - _find_input "${input}" - mediaid=$(basename "${input}" | cut -d. -f1) - ingestlog="${logdir}/capture.log" + _find_input "${INPUT}" + MEDIAID=$(basename "${INPUT}" | cut -d. -f1) + INGESTLOG="${LOGDIR}/capture.log" _set_up_output # get information on the input - get_height "${sourcefile}" - get_width "${sourcefile}" - _get_seconds "${sourcefile}" + _get_height "${SOURCEFILE}" + _get_width "${SOURCEFILE}" + _get_seconds "${SOURCEFILE}" # clear local arrays - unset inputoptions - unset middleoptions - unset audiomapping_ffmpeg + unset INPUTOPTIONS + unset MIDDLEOPTIONS + unset AUDIOMAPPING_FFMPEG # encoding options - get_codectagstring "${sourcefile}" - get_videostreamcount "${sourcefile}" - get_audiostreamcount "${sourcefile}" - inputoptions+=(-vsync 0) - inputoptions+=(-nostdin) + _get_codectagstring "${SOURCEFILE}" + _get_videostreamcount "${SOURCEFILE}" + _get_audiostreamcount "${SOURCEFILE}" + INPUTOPTIONS+=(-vsync 0) + INPUTOPTIONS+=(-nostdin) if [[ "${VIDEOSTREAMCOUNT}" > 0 ]] ; then - if [[ "${codec_tag_string}" == "mjp2" ]] ; then - inputoptions+=(-vcodec libopenjpeg) + if [[ "${CODEC_TAG_STRING}" == "mjp2" ]] ; then + INPUTOPTIONS+=(-vcodec libopenjpeg) fi - middleoptions+=(-movflags faststart) - middleoptions+=(-pix_fmt yuv420p) - middleoptions+=(-c:v libx264) - middleoptions+=(-crf 18) - if [ "${seconds%.*}" -gt "7200" ] ; then - middleoptions+=(-maxrate 2190k) - elif [ "${seconds%.*}" -gt "3600" ] ; then - middleoptions+=(-maxrate 4380k) + MIDDLEOPTIONS+=(-movflags faststart) + MIDDLEOPTIONS+=(-pix_fmt yuv420p) + MIDDLEOPTIONS+=(-c:v libx264) + MIDDLEOPTIONS+=(-crf 18) + if [ "${SECONDS%.*}" -gt "7200" ] ; then + MIDDLEOPTIONS+=(-maxrate 2190k) + elif [ "${SECONDS%.*}" -gt "3600" ] ; then + MIDDLEOPTIONS+=(-maxrate 4380k) else - middleoptions+=(-maxrate 8760k) + MIDDLEOPTIONS+=(-maxrate 8760k) fi - middleoptions+=(-bufsize 1835k) - if [[ "${width}" == 720 && "${height}" == 486 ]] ; then - middleoptions+=(-vf "crop=720:480:0:4,yadif") - elif [[ "${width}" == 720 && "${height}" == 512 ]] ; then - middleoptions+=(-vf "crop=720:480:0:32,yadif") + MIDDLEOPTIONS+=(-bufsize 1835k) + if [[ "${WIDTH}" == 720 && "${HEIGHT}" == 486 ]] ; then + MIDDLEOPTIONS+=(-vf "crop=720:480:0:4,yadif") + elif [[ "${WIDTH}" == 720 && "${HEIGHT}" == 512 ]] ; then + MIDDLEOPTIONS+=(-vf "crop=720:480:0:32,yadif") else - middleoptions+=(-vf yadif) + MIDDLEOPTIONS+=(-vf yadif) fi fi if [[ "${AUDIOSTREAMCOUNT}" > 0 ]] ; then - middleoptions+=(-c:a aac -strict -2) - middleoptions+=(-ac 2) - middleoptions+=(-b:a 128k) - get_audio_index "${sourcefile}" - if [ "${audiomap}" = "L" ] ; then - audiomapping_ffmpeg=(-map_channel 0.${audio_index_1}.0) - elif [ "${audiomap}" = "R" ] ; then - audiomapping_ffmpeg=(-map_channel 0.${audio_index_1}.1) + MIDDLEOPTIONS+=(-c:a aac -strict -2) + MIDDLEOPTIONS+=(-ac 2) + MIDDLEOPTIONS+=(-b:a 128k) + _get_audio_index "${SOURCEFILE}" + if [ "${AUDIOMAP}" = "L" ] ; then + AUDIOMAPPING_FFMPEG=(-map_channel 0.${AUDIO_INDEX_1}.0) + elif [ "${AUDIOMAP}" = "R" ] ; then + AUDIOMAPPING_FFMPEG=(-map_channel 0.${AUDIO_INDEX_1}.1) else - get_audio_mapping "${sourcefile}" + _get_audio_mapping "${SOURCEFILE}" fi - middleoptions+=(${audiomapping_ffmpeg[@]}) + MIDDLEOPTIONS+=("${AUDIOMAPPING_FFMPEG[@]}") fi - middleoptions+=(-f mp4) + MIDDLEOPTIONS+=(-f mp4) _prep_ffmpeg_log _prep_volume_adjustment - if [ "${concatsource}" != "" ] ; then - ffmpeginput="${concatsource}" + if [ "${CONCATSOURCE}" != "" ] ; then + FFMPEGINPUT="${CONCATSOURCE}" else - ffmpeginput="${sourcefile}" + FFMPEGINPUT="${SOURCEFILE}" fi - _run_critical ffmpeg ${inputoptions[@]} -i "${ffmpeginput}" ${middleoptions[@]} "${output}" + _run_critical ffmpeg "${INPUTOPTIONS[@]}" -i "${FFMPEGINPUT}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}" echo _summarize_make _deliver_output "${MAKEYOUTUBE_DELIVERY_EMAIL_TO}" if [[ "${YOUTUBEUPLOAD}" == "Y" ]] ; then if [ $(which uploadyoutube) ] ; then - report -dt "Attempting to run uploadyoutube on ${output}" - uploadyoutube "${output}" - echo "$(get_iso8601),${output},attempted upload,$?" >> "$HOME/Desktop/upload.log" + _report -dt "Attempting to run uploadyoutube on ${OUTPUT}" + uploadyoutube "${OUTPUT}" + echo "$(_get_iso8601),${OUTPUT},attempted upload,$?" >> "${HOME}/Desktop/upload.log" else - report -wt "$(basename "${output}") qualified for uploadyoutube but it is not installed." + _report -wt "$(basename "${OUTPUT}") qualified for uploadyoutube but it is not installed." fi fi _log -e diff --git a/mmconfig b/mmconfig index 3e41b47a..c07213ba 100755 --- a/mmconfig +++ b/mmconfig @@ -3,81 +3,81 @@ # set up variables for microservices CONFIG="Y" CONFIG_VERSION="1.0" -scriptdir=$(dirname "${0}") -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; +SCRIPTDIR=$(dirname "${0}") +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; # local variables REQUIRED_VARIABLES=("OUTDIR_INGESTFILE" "OUTDIR_INGESTXDCAM" "OUTDIR_PAPER" "AIP_STORAGE" "PODCASTDELIVER" "YOUTUBEDELIVER" "TMPDIR" "REGEX4PODCAST" "DVDLABELPREFIX" "OMNEONIP" "OMNEONPATH" "CUSTOM_LOG_DIR" "LTO_INDEX_DIR" "LOCAL_MM_DIR" "EMAIL_FROM" "MAKEYOUTUBE_DELIVERY_EMAIL_TO" "MAKEBROADCAST_DELIVERY_EMAIL_TO" "FILEMAKER_DB" "FILEMAKER_XML_URL" "VOLADJUST") -config_edit(){ - [ -z "${1}" -o -z "$2" ] && { report -w "The config_edit function requires two arguments. Error." ; exit ;}; - sedtemp=$(maketemp) - sed "s:^$1=[^ ]*:$1=$2:" "$CONFIG_FILE" > "$sedtemp" - cp "$sedtemp" "$CONFIG_FILE" +_config_edit(){ + [ -z "${1}" -o -z "${2}" ] && { _report -w "The config_edit function requires two arguments. Error." ; exit ;}; + SEDTEMP=$(_maketemp) + sed "s:^${1}=[^ ]*:$1=$2:" "${CONFIG_FILE}" > "${SEDTEMP}" + cp "${SEDTEMP}" "${CONFIG_FILE}" } -test_config(){ - for directoryvariable in OUTDIR_INGESTFILE OUTDIR_INGESTXDCAM OUTDIR_PAPER AIP_STORAGE PODCASTDELIVER YOUTUBEDELIVER TMPDIR CUSTOM_LOG_DIR LTO_INDEX_DIR ; do - if [ ! -d "${!directoryvariable}" ] ; then - report -w "${directoryvariable} is NOT a valid directory" +_test_config(){ + for DIRECTORYVARIABLE in OUTDIR_INGESTFILE OUTDIR_INGESTXDCAM OUTDIR_PAPER AIP_STORAGE PODCASTDELIVER YOUTUBEDELIVER TMPDIR CUSTOM_LOG_DIR LTO_INDEX_DIR ; do + if [ ! -d "${!DIRECTORYVARIABLE}" ] ; then + _report -w "${DIRECTORYVARIABLE} is NOT a valid directory" fi done - for booleanvariable in VOLADJUST ; do - if [[ ! "${!booleanvariable}" = "Y" && ! "${!booleanvariable}" = "N" ]] ; then - report -w "${booleanvariable} is NOT set to Y or N" + for BOOLEANVARIABLE in VOLADJUST ; do + if [[ ! "${!BOOLEANVARIABLE}" = "Y" && ! "${!BOOLEANVARIABLE}" = "N" ]] ; then + _report -w "${BOOLEANVARIABLE} is NOT set to Y or N" fi done } -add_key(){ - key_to_add="${1}" - grep -q "^$key_to_add=" "$CONFIG_FILE" ; grep_code="$?" - if [[ ! "${grep_code}" -eq "0" ]] ; then - report -td "Adding NEW variable $key_to_add to $CONFIG_FILE" - echo "$key_to_add=" >> "$CONFIG_FILE" +_add_key(){ + KEY_TO_ADD="${1}" + grep -q "^${KEY_TO_ADD}=" "${CONFIG_FILE}" ; GREP_CODE="$?" + if [[ ! "${GREP_CODE}" -eq "0" ]] ; then + _report -td "Adding NEW variable ${KEY_TO_ADD} to ${CONFIG_FILE}" + echo "${KEY_TO_ADD}=" >> "${CONFIG_FILE}" fi } # set up configuration file if required -if [[ ! -f "$CONFIG_FILE" ]] ; then - echo "# $(basename $CONFIG_FILE)" > "$CONFIG_FILE" - echo "# This configuration file contains variables used throughout $WHAT_IS_THIS." >> "$CONFIG_FILE" - echo "# Edit the lines below to form KEY=VALUE. Please do not add or remove the existing KEYs. Do not edit CONFIG_FILE_VERSION." >> "$CONFIG_FILE" - echo "CONFIG_FILE_VERSION=$CONFIG_VERSION" >> "$CONFIG_FILE" +if [[ ! -f "${CONFIG_FILE}" ]] ; then + echo "# $(basename ${CONFIG_FILE})" > "${CONFIG_FILE}" + echo "# This configuration file contains variables used throughout ${WHAT_IS_THIS}." >> "${CONFIG_FILE}" + echo "# Edit the lines below to form KEY=VALUE. Please do not add or remove the existing KEYs. Do not edit CONFIG_FILE_VERSION." >> "${CONFIG_FILE}" + echo "CONFIG_FILE_VERSION=${CONFIG_VERSION}" >> "${CONFIG_FILE}" fi for KEY in "${REQUIRED_VARIABLES[@]}" ; do - add_key "$KEY" + _add_key "${KEY}" done -report -d "(basename "${0}")" -report -d "Set system variables for ${WHAT_IS_THIS}" +_report -d "(basename "${0}")" +_report -d "Set system variables for ${WHAT_IS_THIS}" echo -report -d "Notes:" -report -d "VOLADJUST must be set to 'Y' or 'N'" +_report -d "Notes:" +_report -d "VOLADJUST must be set to 'Y' or 'N'" echo -report -d "Testing $CONFIG_FILE validity" -test_config +_report -d "Testing ${CONFIG_FILE} validity" +_test_config echo -report -d "Table of existing variables:" +_report -d "Table of existing variables:" for KEY in "${REQUIRED_VARIABLES[@]}" ; do - VALUE=$(grep "^$KEY=" "$CONFIG_FILE" | cut -d= -f2) - printf '\t%-40s %-40s\n' "$KEY" "$VALUE" + VALUE=$(grep "^${KEY}=" "${CONFIG_FILE}" | cut -d= -f2) + printf '\t%-40s %-40s\n' "${KEY}" "${VALUE}" done while true ; do EDITOPTION1="Edit config file in nano" EDITOPTION2="Edit config file in TextMate" - report -q "Edit a variable? " + _report -q "Edit a variable? " PS3="Selection (enter by number)? " - select CONFIG_KEY in "$EDITOPTION1" "$EDITOPTION2" "${REQUIRED_VARIABLES[@]}" "Quit" + select CONFIG_KEY in "${EDITOPTION1}" "${EDITOPTION2}" "${REQUIRED_VARIABLES[@]}" "Quit" do break done - [ "$CONFIG_KEY" = "Quit" ] && { echo Goodbye. ; exit 1 ;}; - [ "$CONFIG_KEY" = "$EDITOPTION1" ] && { nano "$CONFIG_FILE" ; exit 1 ;}; - [ "$CONFIG_KEY" = "$EDITOPTION2" ] && { mate "$CONFIG_FILE" ; exit 1 ;}; - echo -n "Enter the value for $CONFIG_KEY: " + [ "${CONFIG_KEY}" = "Quit" ] && { echo Goodbye. ; exit 1 ;}; + [ "${CONFIG_KEY}" = "${EDITOPTION1}" ] && { nano "${CONFIG_FILE}" ; exit 1 ;}; + [ "${CONFIG_KEY}" = "${EDITOPTION2}" ] && { mate "${CONFIG_FILE}" ; exit 1 ;}; + echo -n "Enter the value for ${CONFIG_KEY}: " read -e "CONFIG_VALUE" - echo "$CONFIG_KEY is now set to $CONFIG_VALUE" - config_edit "$CONFIG_KEY" "$CONFIG_VALUE" + echo "${CONFIG_KEY} is now set to ${CONFIG_VALUE}" + _config_edit "${CONFIG_KEY}" "${CONFIG_VALUE}" done diff --git a/mmfunctions b/mmfunctions index d1d99a0f..045f0684 100755 --- a/mmfunctions +++ b/mmfunctions @@ -6,16 +6,16 @@ WHAT_IS_THIS="mediamicroservices" # load configuration file if [ -f "${CONFIG_FILE}" ] ; then . "${CONFIG_FILE}" -elif [ ! "${CONFIG}" = "Y" -a "${requireconfig}" = "Y" ] ; then +elif [ ! "${CONFIG}" = "Y" -a "${REQUIRECONFIG}" = "Y" ] ; then echo "The configuration file is not set. You amust first create ${CONFIG_FILE} by running mmconfig." 1>&2 exit 1 fi -get_iso8601(){ +_get_iso8601(){ date +%FT%T } -get_iso8601_c(){ +_get_iso8601_c(){ date +%Y%m%d-%I%M%S } @@ -26,13 +26,13 @@ _unset_ffreport(){ } _mkdir2(){ - local dir2make="" + local DIR2MAKE="" while [ "${*}" != "" ] ; do - dir2make="${1}" - if [ ! -d "${dir2make}" ] ; then - mkdir -p "${dir2make}" + DIR2MAKE="${1}" + if [ ! -d "${DIR2MAKE}" ] ; then + mkdir -p "${DIR2MAKE}" if [ "${?}" -ne 0 ]; then - report -wt "${0}: Can't create directory at ${dir2make}" + _report -wt "${0}: Can't create directory at ${DIR2MAKE}" exit 1 fi fi @@ -41,111 +41,112 @@ _mkdir2(){ } _log(){ - mmlogname="mm.log" - mmlogdir="${CUSTOM_LOG_DIR:-/tmp}" - mmlogfile="${mmlogdir}/${mmlogname}" - if [ ! -d "${mmlogdir}" ] ; then - _mkdir2 "${mmlogdir}" + MMLOGNAME="mm.log" + MMLOGDIR="${CUSTOM_LOG_DIR:-/tmp}" + MMLOGFILE="${MMLOGDIR}/${MMLOGNAME}" + if [ ! -d "${MMLOGDIR}" ] ; then + _mkdir2 "${MMLOGDIR}" if [ "${?}" -ne 0 ]; then - echo "${0}: Can't create log directory at ${mmlogdir}, exiting... Use mmconfig to change logging directory." + echo "${0}: Can't create log directory at ${MMLOGDIR}, exiting... Use mmconfig to change logging directory." exit 1 fi fi 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 - w) status+"warning" ;; # warning information + 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 + w) STATUS+"warning" ;; # warning information esac done shift $(( ${OPTIND} - 1 )) - note="${1}" - echo $(get_iso8601)", $(basename "${0}"), ${status}, ${op}, ${mediaid}, ${note}" >> "${mmlogfile}" + NOTE="${1}" + echo $(_get_iso8601)", $(basename "${0}"), ${STATUS}, ${OP}, ${MEDIAID}, ${NOTE}" >> "${MMLOGFILE}" } -report(){ +_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="" - local log_message="" + local COLOR="" + local STARTMESSAGE="" + local ENDMESSAGE="" + local ECHOOPT="" + local LOG_MESSAGE="" OPTIND=1 - while getopts ":qdwstn" 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_message="Y";; # warning mode, use color red - s) startmessage+=([$(basename "${0}")] ) ;; # prepend scriptname to the message - t) startmessage+=($(get_iso8601) '- ' ) ;; # prepend timestamp to the message - n) echoopt="-n" ;; # to avoid line breaks after echo + while getopts ":qdwstn" 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_MESSAGE="Y";; # warning mode, use color red + s) STARTMESSAGE+=([$(basename "${0}")] ) ;; # prepend scriptname to the message + t) STARTMESSAGE+=($(_get_iso8601) '- ' ) ;; # prepend timestamp 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_message" = "Y" ] && _log -w "${message}" + MESSAGE="${1}" + echo "${ECHOOPT}" "${COLOR}${STARTMESSAGE[@]}${MESSAGE}${NC}" + [ "${LOG_MESSAGE}" = "Y" ] && _log -w "${MESSAGE}" } _writeingestlog(){ - if [ "${ingestlog}" ] ; then - key="${1}" - value="$2" + if [ "${INGESTLOG}" ] ; then + KEY="${1}" + VALUE="${2}" # need to add yaml style escaping - echo "$key: ${value}" >> "${ingestlog}" + echo "${KEY}: ${VALUE}" >> "${INGEST + }" else - report -wt "The _writeingestlog function was called but the ingestlog file (${ingestlog}) is not declared." + _report -wt "The _writeingestlog function was called but the ingestlog file (${INGESTLOG}) is not declared." fi } _readingestlog(){ - if [ -f "${ingestlog}" ] ; then - key="${1}" + if [ -f "${INGESTLOG}" ] ; then + KEY="${1}" # need to add yaml style escaping - grep "^${1}:" "${ingestlog}" | cut -d: -f2- | sed 's/ //g' + grep "^${1}:" "${INGESTLOG}" | cut -d: -f2- | sed 's/ //g' else - report -wt "The _readingestlog function was called but the ingestlog file (${ingestlog}) is not declared." + _report -wt "The _readingestlog function was called but the ingestlog file (${INGESTLOG}) is not declared." fi } _run(){ - run_err="" - report -sdt "Running: ${*}" + RUN_ERR="" + _report -sdt "Running: ${*}" if [[ ! "${DRYRUN}" == true ]] ; then "${@}" fi - run_err="${?}" - if [[ "${run_err}" != 0 ]] ; then - report -wts "Error: Running: \"${*}\" gave an Error Code - ${run_err}" + RUN_ERR="${?}" + if [[ "${RUN_ERR}" != 0 ]] ; then + _report -wts "Error: Running: \"${*}\" gave an Error Code - ${RUN_ERR}" fi } _run_critical(){ _run "${@}" - if [[ "${run_err}" != 0 ]] ; then - report -wts "The process ran into a critical error and can not proceed." + if [[ "${RUN_ERR}" != 0 ]] ; then + _report -wts "The process ran into a critical error and can not proceed." exit 1 fi } -black_at_ends(){ - input_movie="${1}" - analysis_head_seconds=10 - analysis_tail_seconds=-10 - report -dt "Analyzing $(basename "${input_movie}") for excessive black at head or tail." - 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 -sseof "${analysis_tail_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 last ${analysis_head_seconds} seconds: ${tail_black}." +_black_at_ends(){ + INPUT_MOVIE="${1}" + ANALYSIS_HEAD_SECONDS=10 + ANALYSIS_TAIL_SECONDS=-10 + _report -dt "Analyzing $(basename "${INPUT_MOVIE}") for excessive black at head or tail." + 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 -sseof "${ANALYSIS_TAIL_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 last ${ANALYSIS_HEAD_SECONDS} seconds: ${TAIL_BLACK}." } -maketemp(){ +_maketemp(){ mktemp -q "/tmp/$(basename "${0}").XXXXXX" if [ "${?}" -ne 0 ]; then echo "${0}: Can't create temp file, exiting..." @@ -153,60 +154,60 @@ maketemp(){ fi } -ask_operator(){ - if [ -z "${op}" ] ; then - report -qn "Enter the name of the operator or 'q' to quit: " - read -e op - [ -z "${op}" ] && ask_operator || log+="operator: ${op}\n" - [ "${op}" == "q" ] && exit 0 +_ask_operator(){ + if [ -z "${OP}" ] ; then + _report -qn "Enter the name of the operator or 'q' to quit: " + read -e 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 -e mediaid - [ -z "${mediaid}" ] && ask_mediaid +_ask_mediaid(){ + if [ -z "${MEDIAID}" ] ; then + _report -qn "Enter a unique MEDIA ID: " + read -e MEDIAID + [ -z "${MEDIAID}" ] && _ask_mediaid # option to quit - [ "${mediaid}" == "q" ] && exit 0 + [ "${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 ;}; + [ -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" + [ ! -z "${MEDIAID}" ] && LOG+="mediaid: ${MEDIAID}\n" } -ask_input(){ - if [ -z "${input}" ] ; then - report -qn "Drag in the file: " - read -e input - [ -z "${input}" ] && ask_input - [ "${input}" == "q" ] && exit 0 - basename=$(basename "${input}") - [ ! -z "${input}" ] && log+="input: ${input}\n" +_ask_input(){ + if [ -z "${INPUT}" ] ; then + _report -qn "Drag in the file: " + read -e INPUT + [ -z "${INPUT}" ] && _ask_input + [ "${INPUT}" == "q" ] && exit 0 + basename=$(basename "${INPUT}") + [ ! -z "${INPUT}" ] && LOG+="input: ${INPUT}\n" fi } -ask_trimmed_materials(){ - report -qn "Drag in any trimmed materials: " - read -e -a trimmed - [ "$trimmed[0]" == "q" ] && exit 0 - [ ! -z "${trimmed}" ] && log+="trimmed_materials: ${trimmed}\n" +_ask_trimmed_materials(){ + _report -qn "Drag in any trimmed materials: " + read -e -a TRIMMED + [ "${TRIMMED[0]}" == "q" ] && exit 0 + [ ! -z "${TRIMMED}" ] && LOG+="trimmed_materials: ${TRIMMED}\n" } _ask_intime(){ # TIME_REGEX tests for either S.mmm or HH:MM:SS.mmm time formats where HH is two digit hour, MM is two digit minute, S is number of seconds, SS is two digit seconds, and .mmm is milliseconds from between 0 and 3 decimals TIME_REGEX="^\([0-9]\+\(\.[0-9]\{1,3\}\)\?\|[0-9]\{2\}:[0-5][0-9]:[0-5][0-9]\(\.[0-9]\{1,3\}\)\?\)$" - while [[ ! $(echo "$intime" | grep "${TIME_REGEX}") ]] ; do - report -q "Enter point of time to start transcoding." - report -q "Enter no value if no intime for transcoding is needed. Transcoding will then start from the beginning." - report -q "Must be in HH:MM:SS.mmm or S.mmm format. Note mmm is milliseconds and not frames." - report -qn "Intime: " - read intime - if [[ "${intime}" == "" ]] ; then + while [[ ! $(echo "${INTIME}" | grep "${TIME_REGEX}") ]] ; do + _report -q "Enter point of time to start transcoding." + _report -q "Enter no value if no intime for transcoding is needed. Transcoding will then start from the beginning." + _report -q "Must be in HH:MM:SS.mmm or S.mmm format. Note mmm is milliseconds and not frames." + _report -qn "INTIME: " + read INTIME + if [[ "${INTIME}" == "" ]] ; then break - elif [[ ! $(echo "$intime" | grep "${TIME_REGEX}") ]] ; then - report -w "In time must be in seconds or in HH:MM:SS.mmm format." + elif [[ ! $(echo "${INTIME}" | grep "${TIME_REGEX}") ]] ; then + _report -w "In time must be in seconds or in HH:MM:SS.mmm format." fi done } @@ -214,37 +215,37 @@ _ask_intime(){ _ask_outtime(){ # TIME_REGEX tests for either S.mmm or HH:MM:SS.mmm time formats where HH is two digit hour, MM is two digit minute, S is number of seconds, SS is two digit seconds, and .mmm is milliseconds from between 0 and 3 decimals TIME_REGEX="^\([0-9]\+\(\.[0-9]\{1,3\}\)\?\|[0-9]\{2\}:[0-5][0-9]:[0-5][0-9]\(\.[0-9]\{1,3\}\)\?\)$" - while [[ ! $(echo "$outtime" | grep "${TIME_REGEX}") ]] ; do - report -q "Enter point of time to stop transcoding." - report -q "Enter no value if no outtime for transcoding is needed. Transcoding will proceed to the end." - report -q "Must be in HH:MM:SS.mmm or S.mmm format. Note mmm is milliseconds and not frames." - report -qn "Outtime: " - read outtime - if [[ "${outtime}" == "" ]] ; then + while [[ ! $(echo "${OUTTIME}" | grep "${TIME_REGEX}") ]] ; do + _report -q "Enter point of time to stop transcoding." + _report -q "Enter no value if no outtime for transcoding is needed. Transcoding will proceed to the end." + _report -q "Must be in HH:MM:SS.mmm or S.mmm format. Note mmm is milliseconds and not frames." + _report -qn "OUTTIME: " + read OUTTIME + if [[ "${OUTTIME}" == "" ]] ; then break - elif [[ ! $(echo "$outtime" | grep "${TIME_REGEX}") ]] ; then - report -w "Out time must be in seconds or in HH:MM:SS.mmm format." + elif [[ ! $(echo "${OUTTIME}" | grep "${TIME_REGEX}") ]] ; then + _report -w "Out time must be in seconds or in HH:MM:SS.mmm format." fi done } -check_dependencies(){ - deps_ok=YES +_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 + 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!" + if [[ "${DEPS_OK}" == "NO" ]]; then + _report -wt "Unmet dependencies" + _report -wt "Aborting!" exit 1 else return 0 @@ -252,56 +253,56 @@ check_dependencies(){ } _initialize_make(){ - check_dependencies "${dependencies[@]}" - unset dependencies - deliverdir="" + _check_dependencies "${DEPENDENCIES[@]}" + unset DEPENDENCIES + DELIVERDIR="" DRYRUN=false - emailaddress="" - outputdir_forced="" - cleanup(){ + EMAILADDRESS="" + OUTPUTDIR_FORCED="" + _cleanup(){ _log -a "Process aborted" echo - report -wts "THE PROCESS WAS ABORTED" + _report -wts "THE PROCESS WAS ABORTED" exit 1 } - trap cleanup SIGHUP SIGINT SIGTERM + trap _cleanup SIGHUP SIGINT SIGTERM } -check_deliverdir(){ - if [ ! -d "${deliverdir}" ] ; then - report -wt "The delivery directory, ${deliverdir}, does not exist. Can not deliver the output of $(basename "${0}")." +_check_deliverdir(){ + if [ ! -d "${DELIVERDIR}" ] ; then + _report -wt "The delivery directory, ${DELIVERDIR}, does not exist. Can not deliver the OUTPUT of $(basename "${0}")." fi } _check_outputdir_forced(){ if [ ! -d "${1}" ] ; then - report -wt "The directory, ${1}, does not exist. Can not write the output of $(basename "${0}")." + _report -wt "The directory, ${1}, does not exist. Can not write the output of $(basename "${0}")." fi } check_emailaddress(){ - emailregex="^((\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*([,])*)*$" + EMAILREGEX="^((\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*([,])*)*$" if ! $(echo "${1}" | grep -Eq "^((\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*([,])*)*$") ; then - report -wt "${1} is not a valid email address." + _report -wt "${1} is not a valid email address." fi } _get_duration(){ - ffduration=$(ffprobe "${1}" -show_format -pretty 2> /dev/null | grep "^duration=" | cut -d= -f2) + FFDURATION=$(ffprobe "${1}" -show_format -pretty 2> /dev/null | grep "^duration=" | cut -d= -f2) } _get_seconds(){ - seconds=$(ffprobe "${1}" -show_format 2> /dev/null | grep "^duration=" | cut -d= -f2) + SECONDS=$(ffprobe "${1}" -show_format 2> /dev/null | grep "^duration=" | cut -d= -f2) } -email_delivery(){ - emailto="${1}" - if [ "${emailto}" ] ; then - [ -d "${input}" ] && logdir="${input}/metadata/submissionDocumentation/logs" - [ -f "${input}" ] && logdir="$(dirname "${input}")/service/logs" - ingestlog="${logdir}/capture.log" - _get_duration "${output}" - if [[ -f "${ingestlog}" ]] ; then +_email_delivery(){ + EMAILTO="${1}" + if [ "${EMAILTO}" ] ; then + [ -d "${INPUT}" ] && LOGDIR="${INPUT}/metadata/submissionDocumentation/logs" + [ -f "${INPUT}" ] && LOGDIR="$(dirname "${INPUT}")/service/logs" + INGESTLOG="${LOGDIR}/capture.log" + _get_duration "${OUTPUT}" + if [[ -f "${INGESTLOG}" ]] ; then FROMLOG="Operator: $(_readingestlog "operator")\n Processing Computer: $(_readingestlog "computer_name") Audio Peak (dB): $(_readingestlog "voldet_max_volume") @@ -309,214 +310,214 @@ Integrated Loudness: $(_readingestlog "r128_integrated_loudness") Audio Adjustment: $(_readingestlog "audio_adjustment") Loudness Range: $(_readingestlog "r128_loudness_range")" fi - echo -e "Subject: [delivery] $(basename "${output}")\n -A file has been delivered to ${deliverdir}.\n + echo -e "Subject: [delivery] $(basename "${OUTPUT}")\n +A file has been delivered to ${DELIVERDIR}.\n Process: $(basename "${0}") -MediaID: ${mediaid}\n -Filename: ${output} -Sourcefile: ${sourcefile} -Duration: ${ffduration}\n -Decoding_options: ${inputoptions[@]} -Encoding_options: ${middleoptions[@]}\n +MediaID: ${MEDIAID}\n +Filename: ${OUTPUT} +Sourcefile: ${SOURCEFILE} +Duration: ${FFDURATION}\n +Decoding_options: ${INPUTOPTIONS[@]} +Encoding_options: ${MIDDLEOPTIONS[@]}\n Delivery Exit Status: ${DELIVER_EXIT_STATUS}\n ${FROMLOG} \n -Enjoy!" | sendmail -f "${EMAIL_FROM}" -F "${emailto}" "${emailto}" +Enjoy!" | sendmail -f "${EMAIL_FROM}" -F "${EMAILTO}" "${EMAILTO}" fi } _deliver_output(){ # argument 1 if used should be the email to report delivery to - emailto="${1}" - if [ "${deliverdir}" ] ; then - echo DELIVERING OUTPUT ACTIVITED with "${deliverdir}" - report -dt "Delivering ${output} to ${deliverdir}" - _run cp -av "${output}" "${deliverdir}/" - DELIVER_EXIT_STATUS="$?" - email_delivery "$emailto" + EMAILTO="${1}" + if [ "${DELIVERDIR}" ] ; then + echo DELIVERING OUTPUT ACTIVITED with "${DELIVERDIR}" + _report -dt "Delivering ${OUTPUT} to ${DELIVERDIR}" + _run cp -av "${OUTPUT}" "${DELIVERDIR}/" + DELIVER_EXIT_STATUS="${?}" + _email_delivery "${EMAILTO}" fi } -ask(){ +_ask(){ # This function requires 3 arguments # 1) A prompt # 2) The label for the metadata value - read -e -p "${1}" response - if [ -z "${response}" ] ; then - ask "${1}" "${2}" + read -e -p "${1}" RESPONSE + if [ -z "${RESPONSE}" ] ; then + _ask "${1}" "${2}" else - log+="${2}: ${response}\n" + LOG+="${2}: ${RESPONSE}\n" fi echo } -offerChoice(){ +_offerChoice(){ # This function requires 3 arguments # 1) A prompt # 2) The label for the metadata value # 3) A vocabulary list PS3="${1}" - label="${2}" + LABEL="${2}" eval set "${3}" - select option in "${@}" + select OPTION in "${@}" do break done - log+="${label}: ${option}\n" + LOG+="${LABEL}: ${OPTION}\n" echo } -make_mezz_for_xdcam(){ - som="${1}" - dur="${2}" +_make_mezz_for_xdcam(){ + 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) +_get_width(){ + WIDTH=$(ffprobe "${1}" -show_streams -select_streams v:0 2> /dev/null | grep "^WIDTH=" | cut -d = -f 2) } -get_height(){ - height=$(ffprobe "${1}" -show_streams -select_streams v:0 2> /dev/null | grep "^height=" | cut -d = -f 2) +_get_height(){ + HEIGHT=$(ffprobe "${1}" -show_streams -select_streams v:0 2> /dev/null | grep "^HEIGHT=" | cut -d = -f 2) } -get_dar(){ - dar=$(ffprobe "${1}" -show_streams -select_streams v:0 2> /dev/null | grep "^display_aspect_ratio=" | cut -d = -f 2 | sed 's|:|/|g') - if [ "$dar" = "0/1" ] ; then - get_width "${1}" - get_height "${1}" - dar="${width}/${height}" +_get_dar(){ + DAR=$(ffprobe "${1}" -show_streams -select_streams v:0 2> /dev/null | grep "^display_aspect_ratio=" | cut -d = -f 2 | sed 's|:|/|g') + if [ "${DAR}" = "0/1" ] ; then + _get_width "${1}" + _get_height "${1}" + DAR="${WIDTH}/${HEIGHT}" fi } -get_sar(){ - sar=$(ffprobe "${1}" -show_streams -select_streams v:0 2> /dev/null | grep "^sample_aspect_ratio=" | cut -d = -f 2 | sed 's|:|/|g') - if [ "$sar" = "0/1" ] ; then - sar="1/1" +_get_sar(){ + SAR=$(ffprobe "${1}" -show_streams -select_streams v:0 2> /dev/null | grep "^sample_aspect_ratio=" | cut -d = -f 2 | sed 's|:|/|g') + if [ "${SAR}" = "0/1" ] ; then + SAR="1/1" fi } -has_first_two_tracks_mono(){ +_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 | grep "^channels=" | cut -d= -f2) = "1" ] && \ [ $(ffprobe 2>/dev/null "${1}" -show_streams -select_streams a:1 | grep "^channels=" | cut -d= -f2) = "1" ] && \ MULTIMONO=true } -get_audio_index(){ +_get_audio_index(){ # get ffmpeg's index value of the first audio stream. Useful for do custom channel mappings. - audio_index_1=$(ffprobe "${1}" -show_streams -select_streams a:0 2> /dev/null | grep "^index=" | cut -d = -f 2) - audio_index_2=$(ffprobe "${1}" -show_streams -select_streams a:1 2> /dev/null | grep "^index=" | cut -d = -f 2) + AUDIO_INDEX_1=$(ffprobe "${1}" -show_streams -select_streams a:0 2> /dev/null | grep "^index=" | cut -d = -f 2) + AUDIO_INDEX_2=$(ffprobe "${1}" -show_streams -select_streams a:1 2> /dev/null | grep "^index=" | cut -d = -f 2) } -get_audio_channels(){ +_get_audio_channels(){ # get ffmpeg's channel count of the first audio stream. - audio_channels=$(ffprobe "${1}" -show_streams -select_streams a 2> /dev/null | grep "^channels=" | cut -d = -f 2 | head -n 1) + AUDIO_CHANNELS=$(ffprobe "${1}" -show_streams -select_streams a 2> /dev/null | grep "^channels=" | cut -d = -f 2 | head -n 1) } -get_channel_layout(){ +_get_channel_layout(){ # get ffmpeg's channel count of the first audio stream. - channel_layout=$(ffprobe "${1}" -show_streams -select_streams a 2> /dev/null | grep "^channel_layout=" | cut -d = -f 2 | head -n 1) + CHANNEL_LAYOUT=$(ffprobe "${1}" -show_streams -select_streams a 2> /dev/null | grep "^CHANNEL_LAYOUT=" | cut -d = -f 2 | head -n 1) } -get_audio_mapping(){ - get_audio_index "${1}" - get_audio_channels "${1}" - get_channel_layout "${1}" - has_first_two_tracks_mono "${1}" +_get_audio_mapping(){ + _get_audio_index "${1}" + _get_audio_channels "${1}" + _get_channel_layout "${1}" + _has_first_two_tracks_mono "${1}" if [[ "${MULTIMONO}" == true ]] ; then - report -wt "The first two audio tracks are both mono. Considering track 1 for left and track 2 for right." - audiomapping_ffmpeg=(-map_channel "0.${audio_index_1}.0" -map_channel "0.${audio_index_2}.0") - elif [[ "$audio_channels" -gt 2 && "$channel_layout" == "unknown" ]] ; then - report -wt "The first audio track has more than 2 channels. Considering channel 1 for left and channel 2 for right and ignoring the rest." - audiomapping_ffmpeg=(-map_channel "0.${audio_index_1}.0" -map_channel "0.${audio_index_1}.1") + _report -wt "The first two audio tracks are both mono. Considering track 1 for left and track 2 for right." + AUDIOMAPPING_FFMPEG=(-map_channel "0.${AUDIO_INDEX_1}.0" -map_channel "0.${AUDIO_INDEX_2}.0") + elif [[ "${AUDIO_CHANNELS}" -gt 2 && "${CHANNEL_LAYOUT}" == "unknown" ]] ; then + _report -wt "The first audio track has more than 2 channels. Considering channel 1 for left and channel 2 for right and ignoring the rest." + AUDIOMAPPING_FFMPEG=(-map_channel "0.${AUDIO_INDEX_1}.0" -map_channel "0.${AUDIO_INDEX_1}.1") else - audiomapping_ffmpeg=() + AUDIOMAPPING_FFMPEG=() fi } -get_codectagstring(){ - codec_tag_string=$(ffprobe "${1}" -show_streams -select_streams v:0 2> /dev/null | grep "^codec_tag_string=" | cut -d = -f 2) - if [ "$codec_tag_string" = "FFV1" ] ; then - ffv1_version=$(ffmpeg -debug 1 -i "${1}" -t 0.1 -f null - &1 | grep -o "ver:[0-9]*" | tail -n1 | cut -d: -f2) +_get_codectagstring(){ + CODEC_TAG_STRING=$(ffprobe "${1}" -show_streams -select_streams v:0 2> /dev/null | grep "^CODEC_TAG_STRING=" | cut -d = -f 2) + if [ "${CODEC_TAG_STRING}" = "FFV1" ] ; then + FFV1_VERSION=$(ffmpeg -debug 1 -i "${1}" -t 0.1 -f null - &1 | grep -o "ver:[0-9]*" | tail -n1 | cut -d: -f2) else - ffv1_version="" + FFV1_VERSION="" fi } -get_fieldorder(){ - fieldorder=$(ffprobe-bc "${1}" -show_streams 2> /dev/null | grep "\(progressive\|interlaced=\)" | cut -d = -f 2) +_get_fieldorder(){ + FIELDORDER=$(ffprobe-bc "${1}" -show_streams 2> /dev/null | grep "\(progressive\|interlaced=\)" | cut -d = -f 2) } -get_pix_fmt(){ - pixfmt=$(ffprobe "${1}" -show_streams -select_streams v:0 2> /dev/null | grep "^pix_fmt=" | cut -d = -f 2) +_get_pix_fmt(){ + PIXFMT=$(ffprobe "${1}" -show_streams -select_streams v:0 2> /dev/null | grep "^pix_fmt=" | cut -d = -f 2) } -get_duration(){ +_get_duration(){ DURATION=$(ffprobe "${1}" -show_format 2> /dev/null | grep "^duration=" | cut -d = -f 2) } -get_videostreamcount(){ +_get_videostreamcount(){ VIDEOSTREAMCOUNT=$(ffprobe "${1}" -select_streams v -show_entries stream=index -of flat 2>/dev/null | awk 'END { print NR }') } -get_audiostreamcount(){ +_get_audiostreamcount(){ AUDIOSTREAMCOUNT=$(ffprobe "${1}" -select_streams a -show_entries stream=index -of flat 2>/dev/null | awk 'END { print NR }') } @@ -534,150 +535,150 @@ _get_timecode_overlay(){ TIMECODEOVERLAY=",drawtext=fontfile=/System/Library/Fonts/Monaco.dfont:timecode='${TIMECODEESACPE}':r=30000/1001:fontcolor=white:fontsize=24:shadowx=2:shadowy=2:box=1:boxcolor=gray@0.8:x=w/2-tw/2:y=h*0.8" } -get_maxdvdbitrate(){ - get_duration "${1}" +_get_maxdvdbitrate(){ + _get_duration "${1}" local DVDCAPACITY=33840000000 # in bits, minus 10% local CAPDVDBITRATE=6000000 # in bits/second - MAXDVDBITRATE=$(echo "($DVDCAPACITY - ( $DURATION * 224000 )) / $DURATION" | bc) - report -dt "Data rate could be up to $MAXDVDBITRATE" - if ! [[ "$MAXDVDBITRATE" =~ ^[0-9]+$ ]] ; then - report -wt "Calculation of dvd bitrate failed. Evaluated to ${MAXDVDBITRATE}. Using 4000000 as bitrate instead." + MAXDVDBITRATE=$(echo "(${DVDCAPACITY} - ( ${DURATION} * 224000 )) / ${DURATION}" | bc) + _report -dt "Data rate could be up to ${MAXDVDBITRATE}" + 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" + elif [ "${MAXDVDBITRATE}" -gt "${CAPDVDBITRATE}" ] ; then + MAXDVDBITRATE="${CAPDVDBITRATE}" fi - report -dt "Data rate for DVD is evaluated to $MAXDVDBITRATE" + _report -dt "Data rate for DVD is evaluated to ${MAXDVDBITRATE}" } -is_video(){ +_is_video(){ # use ffmpeg's index value and stream specifier to determine if the input is a recognized as a video file by ffmpeg ffprobe "${1}" -show_streams -select_streams v:0 2> /dev/null | grep "^index=" } -get_volume_adjustment(){ - reference=-24 - integrated_loudness="" - loudness_range="" - voldet_mean_volume="" - voldet_max_volume="" +_get_volume_adjustment(){ + REFERENCE=-24 + INTEGRATED_LOUDNESS="" + LOUDNESS_RANGE="" + VOLDET_MEAN_VOLUME="" + VOLDET_MAX_VOLUME="" VOLADJ="" - input_movie="${1}" - report -dt "Getting volume data for $(basename "${input_movie}") ..." - VOLDETTEMP=$(maketemp) - volume_data=$(ffprobe -of compact=p=0:nk=1:s=',' -show_entries frame_tags=lavfi.r128.I,lavfi.r128.LRA -f lavfi "amovie='${input_movie}',ebur128=metadata=1,volumedetect" 2>"${VOLDETTEMP}") - volume_exit_code="$?" - if [ "${volume_exit_code}" -ne 0 ] ; then - report -wt "Volume analysis for $input_movie exited with ${volume_exit_code}." + INPUT_MOVIE="${1}" + _report -dt "Getting volume data for $(basename "${INPUT_MOVIE}") ..." + VOLDETTEMP=$(_maketemp) + VOLUME_DATA=$(ffprobe -of compact=p=0:nk=1:s=',' -show_entries frame_tags=lavfi.r128.I,lavfi.r128.LRA -f lavfi "amovie='${INPUT_MOVIE}',ebur128=metadata=1,volumedetect" 2>"${VOLDETTEMP}") + VOLUME_EXIT_CODE="${?}" + if [ "${VOLUME_EXIT_CODE}" -ne 0 ] ; then + _report -wt "Volume analysis for ${INPUT_MOVIE} exited with ${VOLUME_EXIT_CODE}." else - for i in $(echo "$volume_data"); do - audioframe_I=$(echo "${i}" | cut -d, -f1) - audioframe_LRA=$(echo "${i}" | cut -d, -f2) - [ "$audioframe_I" != "" ] && integrated_loudness="${audioframe_I}" - [ "$audioframe_LRA" != "" ] && loudness_range="${audioframe_LRA}" + for i in $(echo "${VOLUME_DATA}"); do + AUDIOFRAME_I=$(echo "${i}" | cut -d, -f1) + AUDIOFRAME_LRA=$(echo "${i}" | cut -d, -f2) + [ "${AUDIOFRAME_I}" != "" ] && INTEGRATED_LOUDNESS="${AUDIOFRAME_I}" + [ "${AUDIOFRAME_LRA}" != "" ] && LOUDNESS_RANGE="${AUDIOFRAME_LRA}" done - voldet_mean_volume=$(grep "mean_volume" "${VOLDETTEMP}" | cut -d: -f 2 | awk '{print $1}') - voldet_max_volume=$(grep "max_volume" "${VOLDETTEMP}" | cut -d: -f 2 | awk '{print $1}') - VOLADJ=$(echo "$reference - $integrated_loudness" | bc) + VOLDET_MEAN_VOLUME=$(grep "mean_volume" "${VOLDETTEMP}" | cut -d: -f 2 | awk '{print $1}') + VOLDET_MAX_VOLUME=$(grep "max_volume" "${VOLDETTEMP}" | cut -d: -f 2 | awk '{print $1}') + VOLADJ=$(echo "${REFERENCE} - ${INTEGRATED_LOUDNESS}" | bc) # test to see if adjustment is at least 2dB, else skip - report -dt "Loudness range is ${loudness_range}dB." - if [[ -f "${ingestlog}" ]] ; then + _report -dt "Loudness range is ${LOUDNESS_RANGE}dB." + if [[ -f "${INGESTLOG}" ]] ; then _writeingestlog "audio_adjustment" "${VOLADJ}" - _writeingestlog "r128_loudness_reference" "${reference}" - _writeingestlog "r128_loudness_range" "${loudness_range}" - _writeingestlog "r128_integrated_loudness" "${integrated_loudness}" - _writeingestlog "voldet_mean_volume" "${voldet_mean_volume}" - _writeingestlog "voldet_max_volume" "${voldet_max_volume}" + _writeingestlog "r128_loudness_reference" "${REFERENCE}" + _writeingestlog "r128_loudness_range" "${LOUDNESS_RANGE}" + _writeingestlog "r128_integrated_loudness" "${INTEGRATED_LOUDNESS}" + _writeingestlog "voldet_mean_volume" "${VOLDET_MEAN_VOLUME}" + _writeingestlog "voldet_max_volume" "${VOLDET_MAX_VOLUME}" fi 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:]*") - crop_err="$?" - [ "$crop_err" -ne 0 ] && { report -wt "Crop detection analysis for $input_movie exited with $crop_err." ; exit ;}; - for i in $(echo "$crop_data"); do +_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:]*") + CROP_ERR="${?}" + [ "${CROP_ERR}" -ne 0 ] && { _report -wt "Crop detection analysis for ${INPUT_MOVIE} exited with ${CROP_ERR}." ; exit ;}; + for i in $(echo "${CROP_DATA}"); do [ "$i" != "" ] && CROPADJ="$i" done - report -dt "Crop detection complete. Will crop by ${CROPADJ} (width,height,from_left,from_top) before scaling." + _report -dt "Crop detection complete. Will crop by ${CROPADJ} (width,height,from_left,from_top) before scaling." } -free_space(){ +_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" + 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 } _summarize_make(){ - report -dt "$(basename "${output}") is done." + _report -dt "$(basename "${OUTPUT}") is done." } _prep_ffmpeg_log(){ OPTIND=1 - while getopts ":q" opt ; do - case "${opt}" in - q) nolog="Y";; - *) echo "bad option -$OPTARG" ; usage ;; - :) echo "Option -$OPTARG requires an argument" ; exit 1 ;; + while getopts ":q" OPT ; do + case "${OPT}" in + q) NOLOG="Y";; + *) echo "bad option -${OPTARG}" ; _usage ;; + :) echo "Option -${OPTARG} requires an argument" ; exit 1 ;; esac done shift $(( ${OPTIND} - 1 )) - unset inputoptions - if [ "${logdir}" != "" ] ; then - _mkdir2 "${logdir}" - if [ "${nolog}" = "Y" ] ; then + unset INPUTOPTIONS + if [ "${LOGDIR}" != "" ] ; then + _mkdir2 "${LOGDIR}" + if [ "${NOLOG}" = "Y" ] ; then _unset_ffreport else - export FFREPORT="file=${logdir}/%p_%t_$(basename "${0}")_${version}.txt" + export FFREPORT="file=${LOGDIR}/%p_%t_$(basename "${0}")_${VERSION}.txt" fi - inputoptions+=(-v info) - inputoptions+=(-hide_banner) - inputoptions+=(-stats) + INPUTOPTIONS+=(-v info) + INPUTOPTIONS+=(-hide_banner) + INPUTOPTIONS+=(-stats) else _unset_ffreport fi } -emailoutcome(){ +_emailoutcome(){ # fail only at the moment - MESSAGETEMPFILE=$(maketemp) - echo -e "To: $EMAIL_OUTCOME_TO" > $MESSAGETEMPFILE - echo -e "Subject: ${PACKAGE} failed during ${SCRIPTNAMESHORT}" >> $MESSAGETEMPFILE - echo -e ":(" >> $MESSAGETEMPFILE - sendmail -t < $MESSAGETEMPFILE - rm -f $MESSAGETEMPFILE + MESSAGETEMPFILE=$(_maketemp) + echo -e "To: ${EMAIL_OUTCOME_TO}" > "${MESSAGETEMPFILE}" + echo -e "Subject: ${PACKAGE} failed during ${SCRIPTNAMESHORT}" >> "${MESSAGETEMPFILE}" + echo -e ":(" >> "${MESSAGETEMPFILE}" + sendmail -t < "${MESSAGETEMPFILE}" + rm -f "${MESSAGETEMPFILE}" } _get_filesystem(){ if [ -f "${1}" -o -d "${1}" ] ; then df "${1}" | tail -n1 | cut -d " " -f1 else - report -wt "_get_filesystem was expecting a file or directory but got a ${1}" + _report -wt "_get_filesystem was expecting a file or directory but got a ${1}" fi } -set_accesstimes(){ +_set_accesstimes(){ # set in and out times if used - ingestlog="${logdir}/capture.log" - if [[ -f "${ingestlog}" && "${isobject}" = "Y" ]] ; then - intime=$(_readingestlog "intime") - outtime=$(_readingestlog "outtime") - if [[ "${intime}" ]] ; then - report -dt "ATTENTION: Transcoding will use intime (${intime}) during transcoding." - inputoptions+=(-seek_timestamp 1) - middleoptions+=(-ss "${intime}") + INGESTLOG="${LOGDIR}/capture.log" + if [[ -f "${INGESTLOG}" && "${ISOBJECT}" = "Y" ]] ; then + INTIME=$(_readingestlog "intime") + OUTTIME=$(_readingestlog "outtime") + if [[ "${INTIME}" ]] ; then + _report -dt "ATTENTION: Transcoding will use intime (${INTIME}) during transcoding." + INPUTOPTIONS+=(-seek_timestamp 1) + MIDDLEOPTIONS+=(-ss "${INTIME}") fi - if [[ "${outtime}" ]] ; then - report -dt "ATTENTION: Transcoding will use outtime (${outtime}) during transcoding." - middleoptions+=(-to "${outtime}") + if [[ "${OUTTIME}" ]] ; then + _report -dt "ATTENTION: Transcoding will use outtime (${OUTTIME}) during transcoding." + MIDDLEOPTIONS+=(-to "${OUTTIME}") fi fi } @@ -685,84 +686,84 @@ set_accesstimes(){ _set_up_output(){ # set up output _log -b - output="${outputdir}/${mediaid%.*}${suffix}.${extension}" - if [ -s "${output}" ] ; then - report -wt "WARNING ${output} already exists, skipping transcode" + OUTPUT="${OUTPUTDIR}/${MEDIAID%.*}${SUFFIX}.${EXTENSION}" + if [ -s "${OUTPUT}" ] ; then + _report -wt "WARNING ${OUTPUT} already exists, skipping transcode" shift continue fi - _mkdir2 "${outputdir}" + _mkdir2 "${OUTPUTDIR}" } _prep_volume_adjustment(){ unset VOLADJ if [ "${VOLADJUST}" = "Y" ] ; then - if [[ -f "${ingestlog}" ]] ; then + if [[ -f "${INGESTLOG}" ]] ; then VOLADJ=$(_readingestlog "audio_adjustment") fi if [ "${VOLADJ}" ] ; then - middleoptions+=(-af volume=${VOLADJ}dB) + MIDDLEOPTIONS+=(-af volume=${VOLADJ}dB) else - get_volume_adjustment "${sourcefile}" + _get_volume_adjustment "${SOURCEFILE}" if [ "${VOLADJ}" ] ; then - if [ $(echo "$VOLADJ < 2" |bc) -eq 1 -a $(echo "$VOLADJ > -2" |bc) -eq 1 ] ; then - report -dt "Integrated loudness for $(basename "${input_movie}") is ${integrated_loudness}dB. Reference is ${reference}dB. No adjustment is needed, skipping." + if [ $(echo "${VOLADJ} < 2" |bc) -eq 1 -a $(echo "$VOLADJ > -2" |bc) -eq 1 ] ; then + _report -dt "Integrated loudness for $(basename "${INPUT_MOVIE}") is ${INTEGRATED_LOUDNESS}dB. Reference is ${REFERENCE}dB. No adjustment is needed, skipping." else - report -dt "Integrated loudness for $(basename "${input_movie}") is ${integrated_loudness}dB. Reference is ${reference}dB. Will adjust by ${VOLADJ}dB." - middleoptions+=(-af volume=${VOLADJ}dB) + _report -dt "Integrated loudness for $(basename "${INPUT_MOVIE}") is ${INTEGRATED_LOUDNESS}dB. Reference is ${REFERENCE}dB. Will adjust by ${VOLADJ}dB." + MIDDLEOPTIONS+=(-af volume=${VOLADJ}dB) fi fi fi fi } -pashua_run() { +_pashua_run() { # Wrapper function for interfacing to Pashua. Written by Carsten # Bluem in 10/2003, modified in 12/2003 (including # a code snippet contributed by Tor Sigurdsson), 08/2004 and 12/2004. # Write config file - # Find Pashua binary. We do search both . and dirname "$0" + # Find Pashua binary. We do search both . and dirname "${0}" # , as in a doubleclickable application, cwd is / # BTW, all these quotes below are necessary to handle paths # containing spaces. - bundlepath="Pashua.app/Contents/MacOS/Pashua" - mypath=`dirname "$0"` - for searchpath in "$mypath/Pashua" "$mypath/$bundlepath" "./$bundlepath" \ - "/Applications/$bundlepath" "$HOME/Applications/$bundlepath" + BUNDLEPATH="Pashua.app/Contents/MacOS/Pashua" + MYPATH=`dirname "${0}"` + for SEARCHPATH in "${MYPATH}/Pashua" "${MYPATH}/${BUNDLEPATH}" "./${BUNDLEPATH}" \ + "/Applications/${BUNDLEPATH}" "${HOME}/Applications/${BUNDLEPATH}" do - if [ -f "$searchpath" -a -x "$searchpath" ] + if [ -f "${SEARCHPATH}" -a -x "${SEARCHPATH}" ] then - pashuapath=$searchpath + PASHUAPATH=${SEARCHPATH} break fi done - if [ ! "$pashuapath" ] ; then + if [ ! "${PASHUAPATH}" ] ; then echo "Error: Pashua is used to edit but is not found." - if [[ "${pashuainstall}" == "" ]] ; then + if [[ "${PASHUAINSTALL}" == "" ]] ; then echo "Attempting to run: brew cask install pashua" - if [[ "${pashuainstall}" != "Y" ]] ; then + if [[ "${PASHUAINSTALL}" != "Y" ]] ; then brew cask install pashua - pashuainstall="Y" - pashua_run + PASHUAINSTALL="Y" + _pashua_run else break 2 fi fi else - encoding="" + ENCODING="" # Get result - result=`"$pashuapath" $encoding $pashua_configfile | sed 's/ /;;;/g'` + RESULT=`"${PASHUAPATH}" ${ENCODING} ${PASHUA_CONFIGFILE} | sed 's/ /;;;/g'` # Parse result - for line in $result + for LINE in "${RESULT}" do - key=`echo $line | sed 's/^\([^=]*\)=.*$/\1/'` - value=`echo $line | sed 's/^[^=]*=\(.*\)$/\1/' | sed 's/;;;/ /g'` - varname=$key - varvalue="$value" - eval $varname='$varvalue' + KEY=`echo ${LINE} | sed 's/^\([^=]*\)=.*$/\1/'` + VALUE=`echo ${LINE} | sed 's/^[^=]*=\(.*\)$/\1/' | sed 's/;;;/ /g'` + VARNAME="${KEY}" + VARVALUE="${VALUE}" + eval $VARNAME='$VARVALUE' done fi -} # pashua_run() +} # _pashua_run() diff --git a/mmupdate b/mmupdate index 7076b968..39ae0788 100755 --- a/mmupdate +++ b/mmupdate @@ -2,16 +2,16 @@ # mmupdate # This script is only intended for use with computers that are not connceted to the internet to access github but need to efficiently install updates of mediamicroservices. A local path is setup via mmconfig and running 'mmupdate' will copy relavent files from that declared directory, $LOCAL_MM_DIR, to /usr/local/bin. -scriptdir=`dirname "${0}"` -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; +SCRIPTDIR=`dirname "${0}"` +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; [ -z "${LOCAL_MM_DIR}" ] && { echo "A local directory of mediamicoservice must be declared. Run mmconfig to set LOCAL_MM_DIR." ; exit 1 ;}; -[ ! -d "${LOCAL_MM_DIR}" ] && { echo "mmupdate is configured to use $LOCAL_MM_DIR, which is not available. Run mmconfig to set LOCAL_MM_DIR." ; exit 1 ;}; -for script in barcodeinterpret blackatends checksumpackage fix_left2stereo fix_rewrap fix_volume ingestfile ingestfile makebroadcast makedvd makeframes makelossless makemetadata makepodcast makeprores makeyoutube mmconfig mmfunctions mmhelp paperingest quickcompare removeDSStore uploadomneon xdcamingest mmupdate checksum2filemaker ; do - if [ -f "${LOCAL_MM_DIR}/${script}" ] ; then - rm "/usr/local/bin/${script}" +[ ! -d "${LOCAL_MM_DIR}" ] && { echo "mmupdate is configured to use ${LOCAL_MM_DIR}, which is not available. Run mmconfig to set LOCAL_MM_DIR." ; exit 1 ;}; +for SCRIPT in barcodeinterpret blackatends checksumpackage fix_left2stereo fix_rewrap fix_volume ingestfile ingestfile makebroadcast makedvd makeframes makelossless makemetadata makepodcast makeprores makeyoutube mmconfig mmfunctions mmhelp paperingest quickcompare removeDSStore uploadomneon xdcamingest mmupdate checksum2filemaker ; do + if [ -f "${LOCAL_MM_DIR}/${SCRIPT}" ] ; then + rm "/usr/local/bin/${SCRIPT}" fi - cp -v -f -p "${LOCAL_MM_DIR}/${script}" /usr/local/bin/ + cp -v -f -p "${LOCAL_MM_DIR}/${SCRIPT}" /usr/local/bin/ done if [ -d "${LOCAL_MM_DIR}/extra_installs/" ] ; then cp -v -f -p "${LOCAL_MM_DIR}/extra_installs/"* /usr/local/bin/ diff --git a/paperingest b/paperingest index 86068331..05d78803 100755 --- a/paperingest +++ b/paperingest @@ -1,59 +1,59 @@ #!/bin/bash -requireconfig="Y" +REQUIRECONFIG="Y" -scriptdir=$(dirname "${0}") -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; +SCRIPTDIR=$(dirname "${0}") +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; -cleanup(){ +_cleanup(){ _log -a "Process aborted" exit 1 } -trap cleanup SIGHUP SIGINT SIGTERM +trap _cleanup SIGHUP SIGINT SIGTERM _log -b -ask_operator +_ask_operator -ask_mediaid +_ask_mediaid -if [ -d "$OUTDIR_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." +if [ -d "${OUTDIR_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." exit fi -free_space 5 "$OUTDIR_PAPER" +_free_space 5 "${OUTDIR_PAPER}" -origdir="$OUTDIR_PAPER/$mediaid/objects" -submissionMetadataDir="$OUTDIR_PAPER/$mediaid/metadata/submissionDocumentation" -logdir="$OUTDIR_PAPER/$mediaid/logs" +ORIGDIR="${OUTDIR_PAPER}/${MEDIAID}/objects" +SUBMISSIONMETADATADIR="${OUTDIR_PAPER}/${MEDIAID}/metadata/submissionDocumentation" +LOGDIR="${OUTDIR_PAPER}/${MEDIAID}/logs" -mkdir -p "$origdir" -mkdir -p "$submissionMetadataDir" -mkdir -p "$logdir" +mkdir -p "${ORIGDIR}" +mkdir -p "${SUBMISSIONMETADATADIR}" +mkdir -p "${LOGDIR}" -start=$(date -u "+%Y%m%dT%H%M%SZ") +START=$(date -u "+%Y%m%dT%H%M%SZ") -command="fscanx --adf --rgb --bits 8 --resolution 600 --paper-width 10200 --paper-height 13200 --rotate-n-n --left 0 --width 10200 --top 0 --height 13200 --double-feed n --tiff --no-jpeg --images-per-file 1 --compress zlib '$origdir/${mediaid}_.tif'" -exec &> "$submissionMetadataDir/fscanx_process.txt" -eval "$command" -first=$(find "$origdir" -type f -mindepth 1 -maxdepth 1 ! -name ".*" -exec ls -1rt '{}' \; | head -n 1) -last=$(ls -1t "$origdir" | head -n 1) -open -a /Applications/Preview.app/ "$first" "$origdir/$last" -end=$(date -u "+%Y%m%dT%H%M%SZ") -system_data=$(system_profiler SPHardwareDataType) +COMMAND="fscanx --adf --rgb --bits 8 --resolution 600 --paper-width 10200 --paper-height 13200 --rotate-n-n --left 0 --width 10200 --top 0 --height 13200 --double-feed n --tiff --no-jpeg --images-per-file 1 --compress zlib '${ORIGDIR}/${MEDIAID}_.tif'" +exec &> "${SUBMISSIONMETADATADIR}/fscanx_process.txt" +eval "${COMMAND}" +FIRST=$(find "${ORIGDIR}" -type f -mindepth 1 -maxdepth 1 ! -name ".*" -exec ls -1rt '{}' \; | head -n 1) +LAST=$(ls -1t "${ORIGDIR}" | head -n 1) +open -a /Applications/Preview.app/ "${FIRST}" "${ORIGDIR}/${LAST}" +END=$(date -u "+%Y%m%dT%H%M%SZ") +SYSTEM_DATA=$(system_profiler SPHardwareDataType) #These retrieved the right info on the Mac I'm using, but I don't know how standard the output is -serial_number=$(echo "$system_data" | grep "Serial Number" | awk '{ print $4 }') -model=$(echo "$system_data" | grep "Model Identifier" | awk '{ print $3; }') -os=$(system_profiler SPSoftwareDataType | grep "System Version" | awk '{ print substr($0, index($0,$3)); }') -echo "datetime_start: ${start}" >> "$submissionMetadataDir/operation_process.txt" -echo "datetime_end: ${end}" >> "$submissionMetadataDir/operation_process.txt" -echo "serial number: ${serial_number}" >> "$submissionMetadataDir/operation_process.txt" -echo "model id: ${model}" >> "$submissionMetadataDir/operation_process.txt" -echo "os: ${os}" >> "$submissionMetadataDir/operation_process.txt" -echo "identifier: ${mediaid}" >> "$submissionMetadataDir/operation_process.txt" -echo "operator: ${op}" >> "$submissionMetadataDir/operation_process.txt" -echo "command: ${command}" >> "$submissionMetadataDir/operation_process.txt" - -echo done scanning "$mediaid" +SERIAL_NUMBER=$(echo "${SYSTEM_DATA}" | grep "Serial Number" | awk '{ print $4 }') +MODEL=$(echo "${SYSTEM_DATA}" | grep "Model Identifier" | awk '{ print $3; }') +OS=$(system_profiler SPSoftwareDataType | grep "System Version" | awk '{ print substr(${0}, index(${0},$3)); }') +echo "datetime_start: ${START}" >> "${SUBMISSIONMETADATADIR}/operation_process.txt" +echo "datetime_end: ${END}" >> "${SUBMISSIONMETADATADIR}/operation_process.txt" +echo "serial number: ${SERIAL_NUMBER}" >> "${SUBMISSIONMETADATADIR}/operation_process.txt" +echo "model id: ${MODEL}" >> "${SUBMISSIONMETADATADIR}/operation_process.txt" +echo "os: ${OS}" >> "${SUBMISSIONMETADATADIR}/operation_process.txt" +echo "identifier: ${MEDIAID}" >> "${SUBMISSIONMETADATADIR}/operation_process.txt" +echo "operator: ${OP}" >> "${SUBMISSIONMETADATADIR}/operation_process.txt" +echo "command: ${COMMAND}" >> "${SUBMISSIONMETADATADIR}/operation_process.txt" + +echo done scanning "${MEDIAID}" _log -e diff --git a/quickcompare b/quickcompare index 75f6c5a1..72c5c93f 100755 --- a/quickcompare +++ b/quickcompare @@ -2,20 +2,20 @@ checksize=512000 # quick file compare, not completely authoritative but decent in a short amount of time -scriptdir=$(dirname "${0}") -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; +SCRIPTDIR=$(dirname "${0}") +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; -cleanup(){ +_cleanup(){ _log -a "Process aborted" exit 1 } -trap cleanup SIGHUP SIGINT SIGTERM +trap _cleanup SIGHUP SIGINT SIGTERM _log -b -[ ! "$#" = "2" ] && { echo Use two possibly similar files are arguments. ; exit 1 ;}; +[ ! "${#}" = "2" ] && { echo Use two possibly similar files are arguments. ; exit 1 ;}; #[ ! $(du "${1}" | cut -f1) = $(du "$2" | cut -f1) ] && echo The files are different sizes -[ ! $(head -c "$checksize" "${1}" | md5) = $(head -c "$checksize" "$2" | md5) ] && echo The first "$checksize" bytes have different md5s. -[ ! $(tail -c "$checksize" "${1}" | md5) = $(tail -c "$checksize" "$2" | md5) ] && echo The last "$checksize" bytes have different md5s. +[ ! $(head -c "${CHECKSIZE}" "${1}" | md5) = $(head -c "${CHECKSIZE}" "${2}" | md5) ] && echo The first "${CHECKSIZE}" bytes have different md5s. +[ ! $(tail -c "${CHECKSIZE}" "${1}" | md5) = $(tail -c "${CHECKSIZE}" "${2}" | md5) ] && echo The last "${CHECKSIZE}" bytes have different md5s. _log -e diff --git a/removeDSStore b/removeDSStore index aa014269..4217fe20 100755 --- a/removeDSStore +++ b/removeDSStore @@ -1,21 +1,21 @@ #!/bin/bash # @author Dave Rice -scriptdir=$(dirname "${0}") -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; +SCRIPTDIR=$(dirname "${0}") +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; -cleanup(){ +_cleanup(){ _log -a "Process aborted" exit 1 } -trap cleanup SIGHUP SIGINT SIGTERM +trap _cleanup SIGHUP SIGINT SIGTERM _log -b while [ "${*}" != "" ] ; do - target=$1 - if [ -d "$target" ]; then - find "$target" -name '.DS_Store' -type f -delete + TARGET=${1} + if [ -d "${TARGET}" ]; then + find "${TARGET}" -name '.DS_Store' -type f -delete fi shift done diff --git a/restructureForCompliance b/restructureForCompliance index 638f25eb..d6ab5e27 100755 --- a/restructureForCompliance +++ b/restructureForCompliance @@ -21,33 +21,33 @@ # @author Joseph Perry # @version svn: $Id: 9e1ecac84215aaafd740d15eb0cbdc4c17b7fa1e $ -scriptdir=$(dirname $(which "${0}")) -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; +SCRIPTDIR=$(dirname $(which "${0}")) +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; -target="${1}" +TARGET="${1}" -if [ -d "${target}" ]; then - mkdir "${target}/objects" - mv $(find "${target}" -mindepth 1 -maxdepth 1 ! -name "objects") "${target}objects/" - mkdir -p "${target}/metadata/submissionDocumentation" - mkdir -p "${target}/metadata/submissionDocumentation/fileMeta" - mkdir -p "${target}/metadata/submissionDocumentation/logs" -elif [ -f "${target}" -a ! -d "$(dirname "${target}")/$(basename "${target%.*}")" ]; then - report -qn "Enter the Media ID: " - read mediaid - mkdir -p "$(dirname "${target}")/${mediaid}/objects" - mv "$target" "$(dirname "${target}")/${mediaid}/objects/" - mkdir -p "$(dirname "${target}")/${mediaid}/metadata/submissionDocumentation/fileMeta" - logdir="$(dirname "${target}")/${mediaid}/metadata/submissionDocumentation/logs" - mkdir -p "${logdir}" +if [ -d "${TARGET}" ]; then + mkdir "${TARGET}/objects" + mv $(find "${TARGET}" -mindepth 1 -maxdepth 1 ! -name "objects") "${TARGET}objects/" + mkdir -p "${TARGET}/metadata/submissionDocumentation" + mkdir -p "${TARGET}/metadata/submissionDocumentation/fileMeta" + mkdir -p "${TARGET}/metadata/submissionDocumentation/logs" +elif [ -f "${TARGET}" -a ! -d "$(dirname "${TARGET}")/$(basename "${TARGET%.*}")" ]; then + _report -qn "Enter the Media ID: " + read MEDIAID + mkdir -p "$(dirname "${TARGET}")/${MEDIAID}/objects" + mv "${TARGET}" "$(dirname "${TARGET}")/${MEDIAID}/objects/" + mkdir -p "$(dirname "${TARGET}")/${MEDIAID}/metadata/submissionDocumentation/fileMeta" + LOGDIR="$(dirname "${TARGET}")/${MEDIAID}/metadata/submissionDocumentation/logs" + mkdir -p "${LOGDIR}" _ask_intime - ingestlog="${logdir}/capture.log" - if [ "${intime}" ] ; then - _writeingestlog "intime" "${intime}" + INGESTLOG="${LOGDIR}/capture.log" + if [ "${INTIME}" ] ; then + _writeingestlog "intime" "${INTIME}" fi _ask_outtime - if [ "${outtime}" ] ; then - _writeingestlog "outtime" "${outtime}" + if [ "${OUTTIME}" ] ; then + _writeingestlog "outtime" "${OUTTIME}" fi else echo Error: Needs SIP directory or file as argument 1>&2 diff --git a/uploadomneon b/uploadomneon index 63fad9a7..7c60eaaa 100755 --- a/uploadomneon +++ b/uploadomneon @@ -1,116 +1,116 @@ #!/bin/bash # uploadomneon # upload to omneon -requireconfig="Y" +REQUIRECONFIG="Y" -version="1.0" +VERSION="1.0" -scriptdir=$(dirname "${0}") -. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; +SCRIPTDIR=$(dirname "${0}") +. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; -usage(){ +_usage(){ echo - echo "$(basename "${0}") ${version}" + echo "$(basename "${0}") ${VERSION}" echo "This application will upload file(s) to a server via rsync in sequential order. Options are specified via 'mmconfig'." echo echo "Settings:" echo "OMNEONIP=${OMNEONIP}" echo "OMNEONPATH=${OMNEONPATH}" echo "TMPDIR=${TMPDIR}" - echo "Usage: $(basename $0) file1 [ file2 ...]" + echo "Usage: $(basename ${0}) file1 [ file2 ...]" echo " -h ( display this help )" echo exit } -[ "$#" = 0 ] && usage +[ "${#}" = 0 ] && _usage -cleanup(){ +_cleanup(){ _log -a "Process aborted" exit 1 } get_ftp_status(){ -local filename="${1}" -status=$(ftp -a "$OMNEONIP" < 1 ]] ; then - echo error. The clip directory of "$deviceid1" has more than 1 MXF file. + 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) + 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" + 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" + _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)" + _report -dt "starting initial checksum and packaging..." + bag baginplace "${OUTDIR_INGESTXDCAM}/${DEVICEID1}" + _report -dt "done with ${DEVICEID1} at $(date)" fi fi done