From 7af8bc1e8e36a3ee130c9cd8c85b930caa9f0ffc Mon Sep 17 00:00:00 2001 From: Andrew Weaver Date: Mon, 27 Nov 2017 12:55:36 -0800 Subject: [PATCH 1/8] add variable substitution for mac/linux --- mmfunctions | 19 ++++++++++++++----- searchfingerprint | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/mmfunctions b/mmfunctions index aeaa902e..1640d92b 100755 --- a/mmfunctions +++ b/mmfunctions @@ -12,6 +12,15 @@ elif [ ! "${CONFIG}" = "Y" -a "${REQUIRECONFIG}" = "Y" ] ; then exit 1 fi +#Setup differences for systems +if [[ "$(uname -s)" = "Darwin" ]] ; then + FFMPEGFONTPATH='/Library/Fonts/Andale Mono.ttf' + XMLSTARLET='xml sel' +else + FFMPEGFONTPATH='/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf' + XMLSTARLET='xmlstarlet sel' +fi + _cleanup_mount_dir(){ if [ -d "${MOUNT_DIR}" ] ; then echo calling umount @@ -86,7 +95,7 @@ _report_schema_db(){ if [ -z "${xmlschema}" ] ; then xmlschema="$LTO_LOGS/${TAPE_SERIAL}.schema" fi - schema_sorted=$(xml sel -t -m ".//file" -v "concat(name,'|',length, '|', modifytime)" -o "|" -m "ancestor-or-self::directory" -v "name" -o "/" -b -n "${xmlschema}") + schema_sorted=$("${XMLSTARLET}" -t -m ".//file" -v "concat(name,'|',length, '|', modifytime)" -o "|" -m "ancestor-or-self::directory" -v "name" -o "/" -b -n "${xmlschema}") schema_tape=$(basename "${xmlschema}" | cut -d'.' -f1) IFS=$(echo -en "\n\b") (for i in ${schema_sorted}; do LINE=$i; @@ -236,7 +245,7 @@ _db_error_check(){ } _fingerprint_to_db(){ -VIDEOFINGERPRINT=$(xml sel -N "m=urn:mpeg:mpeg7:schema:2001" -t -m "m:Mpeg7/m:DescriptionUnit/m:Descriptor/m:VideoSignatureRegion/m:VSVideoSegment" -v m:StartFrameOfSegment -o ':' -v m:EndFrameOfSegment -o ':' -m m:BagOfWords -v "translate(.,' ','')" -o ':' -b -n "${FINGERPRINT_XML}") +VIDEOFINGERPRINT=$("${XMLSTARLET}" -N "m=urn:mpeg:mpeg7:schema:2001" -t -m "m:Mpeg7/m:DescriptionUnit/m:Descriptor/m:VideoSignatureRegion/m:VSVideoSegment" -v m:StartFrameOfSegment -o ':' -v m:EndFrameOfSegment -o ':' -m m:BagOfWords -v "translate(.,' ','')" -o ':' -b -n "${FINGERPRINT_XML}") } _premis_event_list(){ @@ -991,10 +1000,10 @@ _find_input (){ fi elif [[ "${SOURCEFILE#*.}" = "mkv" ]] ; then # if the sorucefile is an mkv, then check if it has a Presentation Chapter Edition - if [[ -n $(mkvextract tags "${SOURCEFILE}" | xml sel -t -m "/Tags/Tag/Simple[String='Presentation']" -v String) ]] ; then + if [[ -n $(mkvextract tags "${SOURCEFILE}" | "${XMLSTARLET}" -t -m "/Tags/Tag/Simple[String='Presentation']" -v String) ]] ; then _report -dt "The input file ($(basename "${SOURCEFILE}")) contains a Chapter Edition called 'Presentation', will use that for transcoding." - LISTCHAPTERS=$(mkvextract chapters "${SOURCEFILE}" | xml sel -t -m Chapters/EditionEntry[EditionFlagDefault='1']/ChapterAtom -v ChapterTimeStart -o "-" -v ChapterTimeEnd -o "-" -v ChapterSegmentUID -n -) - SegmentUIDs=$(mkvextract chapters "${SOURCEFILE}" | xml sel -t -m Chapters/EditionEntry[EditionFlagDefault='1']/ChapterAtom/ChapterSegmentUID -v . -n | sort -u) + LISTCHAPTERS=$(mkvextract chapters "${SOURCEFILE}" | "${XMLSTARLET}" -t -m Chapters/EditionEntry[EditionFlagDefault='1']/ChapterAtom -v ChapterTimeStart -o "-" -v ChapterTimeEnd -o "-" -v ChapterSegmentUID -n -) + SegmentUIDs=$(mkvextract chapters "${SOURCEFILE}" | "${XMLSTARLET}" -t -m Chapters/EditionEntry[EditionFlagDefault='1']/ChapterAtom/ChapterSegmentUID -v . -n | sort -u) if [[ -n "${LISTCHAPTERS}" ]]; then _report -d "Found this chapter list:" _report -d "${LISTCHAPTERS}" diff --git a/searchfingerprint b/searchfingerprint index 7971d438..8219ce2a 100755 --- a/searchfingerprint +++ b/searchfingerprint @@ -174,5 +174,5 @@ while [ "${*}" != "" ] ; do done #Play footage from input for which possible matches were found if ! [ "${MODE}" = 'text' ] ; then - ffplay -hide_banner -loglevel panic -f concat -safe 0 -i "${VISUALRESULTS}" -vf drawtext=fontcolor=white:box=1:boxcolor=black@.4:fontsize=20:fontfile="/Library/Fonts/Andale Mono.ttf":textfile="${DRAWTEXT}" + ffplay -hide_banner -loglevel panic -f concat -safe 0 -i "${VISUALRESULTS}" -vf drawtext=fontcolor=white:box=1:boxcolor=black@.4:fontsize=20:fontfile="${FFMPEGFONTPATH}":textfile="${DRAWTEXT}" fi From 5a71093471af61abb1f2349d0c1808ad1998a2c1 Mon Sep 17 00:00:00 2001 From: Weaver Date: Mon, 27 Nov 2017 13:21:24 -0800 Subject: [PATCH 2/8] tweak to tweak --- mmfunctions | 14 +++++++------- searchfingerprint | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mmfunctions b/mmfunctions index 1640d92b..5656b482 100755 --- a/mmfunctions +++ b/mmfunctions @@ -15,10 +15,10 @@ fi #Setup differences for systems if [[ "$(uname -s)" = "Darwin" ]] ; then FFMPEGFONTPATH='/Library/Fonts/Andale Mono.ttf' - XMLSTARLET='xml sel' + XMLSTARLET='xml' else FFMPEGFONTPATH='/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf' - XMLSTARLET='xmlstarlet sel' + XMLSTARLET='xmlstarlet' fi _cleanup_mount_dir(){ @@ -95,7 +95,7 @@ _report_schema_db(){ if [ -z "${xmlschema}" ] ; then xmlschema="$LTO_LOGS/${TAPE_SERIAL}.schema" fi - schema_sorted=$("${XMLSTARLET}" -t -m ".//file" -v "concat(name,'|',length, '|', modifytime)" -o "|" -m "ancestor-or-self::directory" -v "name" -o "/" -b -n "${xmlschema}") + schema_sorted=$("${XMLSTARLET}" sel -t -m ".//file" -v "concat(name,'|',length, '|', modifytime)" -o "|" -m "ancestor-or-self::directory" -v "name" -o "/" -b -n "${xmlschema}") schema_tape=$(basename "${xmlschema}" | cut -d'.' -f1) IFS=$(echo -en "\n\b") (for i in ${schema_sorted}; do LINE=$i; @@ -245,7 +245,7 @@ _db_error_check(){ } _fingerprint_to_db(){ -VIDEOFINGERPRINT=$("${XMLSTARLET}" -N "m=urn:mpeg:mpeg7:schema:2001" -t -m "m:Mpeg7/m:DescriptionUnit/m:Descriptor/m:VideoSignatureRegion/m:VSVideoSegment" -v m:StartFrameOfSegment -o ':' -v m:EndFrameOfSegment -o ':' -m m:BagOfWords -v "translate(.,' ','')" -o ':' -b -n "${FINGERPRINT_XML}") +VIDEOFINGERPRINT=$("${XMLSTARLET}" sel -N "m=urn:mpeg:mpeg7:schema:2001" -t -m "m:Mpeg7/m:DescriptionUnit/m:Descriptor/m:VideoSignatureRegion/m:VSVideoSegment" -v m:StartFrameOfSegment -o ':' -v m:EndFrameOfSegment -o ':' -m m:BagOfWords -v "translate(.,' ','')" -o ':' -b -n "${FINGERPRINT_XML}") } _premis_event_list(){ @@ -1000,10 +1000,10 @@ _find_input (){ fi elif [[ "${SOURCEFILE#*.}" = "mkv" ]] ; then # if the sorucefile is an mkv, then check if it has a Presentation Chapter Edition - if [[ -n $(mkvextract tags "${SOURCEFILE}" | "${XMLSTARLET}" -t -m "/Tags/Tag/Simple[String='Presentation']" -v String) ]] ; then + if [[ -n $(mkvextract tags "${SOURCEFILE}" | "${XMLSTARLET}" sel -t -m "/Tags/Tag/Simple[String='Presentation']" -v String) ]] ; then _report -dt "The input file ($(basename "${SOURCEFILE}")) contains a Chapter Edition called 'Presentation', will use that for transcoding." - LISTCHAPTERS=$(mkvextract chapters "${SOURCEFILE}" | "${XMLSTARLET}" -t -m Chapters/EditionEntry[EditionFlagDefault='1']/ChapterAtom -v ChapterTimeStart -o "-" -v ChapterTimeEnd -o "-" -v ChapterSegmentUID -n -) - SegmentUIDs=$(mkvextract chapters "${SOURCEFILE}" | "${XMLSTARLET}" -t -m Chapters/EditionEntry[EditionFlagDefault='1']/ChapterAtom/ChapterSegmentUID -v . -n | sort -u) + LISTCHAPTERS=$(mkvextract chapters "${SOURCEFILE}" | "${XMLSTARLET}" sel -t -m Chapters/EditionEntry[EditionFlagDefault='1']/ChapterAtom -v ChapterTimeStart -o "-" -v ChapterTimeEnd -o "-" -v ChapterSegmentUID -n -) + SegmentUIDs=$(mkvextract chapters "${SOURCEFILE}" | "${XMLSTARLET}" sel -t -m Chapters/EditionEntry[EditionFlagDefault='1']/ChapterAtom/ChapterSegmentUID -v . -n | sort -u) if [[ -n "${LISTCHAPTERS}" ]]; then _report -d "Found this chapter list:" _report -d "${LISTCHAPTERS}" diff --git a/searchfingerprint b/searchfingerprint index 8219ce2a..a78a7063 100755 --- a/searchfingerprint +++ b/searchfingerprint @@ -75,7 +75,7 @@ while [ "${*}" != "" ] ; do #Create Fingerprint ffmpeg -f concat -safe 0 -i "${IO}" -vf signature=format=xml:filename="${TEMPFINGERPRINT}" -map 0:v -f null - - xml sel -N "m=urn:mpeg:mpeg7:schema:2001" -t -m "m:Mpeg7/m:DescriptionUnit/m:Descriptor/m:VideoSignatureRegion/m:VSVideoSegment" -v m:StartFrameOfSegment -o ':' -v m:EndFrameOfSegment -o ':' -m m:BagOfWords -v "translate(.,' ','')" -o ':' -b -n "${TEMPFINGERPRINT}" > "${TEMPFINGERPRINT_SORTED}" + "${XMLSTARLET}" sel -N "m=urn:mpeg:mpeg7:schema:2001" -t -m "m:Mpeg7/m:DescriptionUnit/m:Descriptor/m:VideoSignatureRegion/m:VSVideoSegment" -v m:StartFrameOfSegment -o ':' -v m:EndFrameOfSegment -o ':' -m m:BagOfWords -v "translate(.,' ','')" -o ':' -b -n "${TEMPFINGERPRINT}" > "${TEMPFINGERPRINT_SORTED}" #Sort extract relevant values from fingerprint and sort for parsing (IFS=$'\n' From 883ed2f1f4c10b1e31fe9906599cf7586eaa0999 Mon Sep 17 00:00:00 2001 From: Weaver Date: Mon, 27 Nov 2017 13:22:14 -0800 Subject: [PATCH 3/8] change file query --- searchfingerprint | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searchfingerprint b/searchfingerprint index a78a7063..142ca3c6 100755 --- a/searchfingerprint +++ b/searchfingerprint @@ -40,7 +40,7 @@ while [ "${*}" != "" ] ; do shift #Confirm input is a video file - if [[ -z $(file -Ib "${INPUT}" | grep video) ]] ; then + if [[ -z $(file -i "${INPUT}" | grep video) ]] ; then echo "Input is not a video file" && continue fi From d5505daa4cc7518edb8914bf263e88b1187817fc Mon Sep 17 00:00:00 2001 From: Weaver Date: Tue, 5 Dec 2017 15:39:35 -0800 Subject: [PATCH 4/8] make system check more specific switch to echo --- mmfunctions | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mmfunctions b/mmfunctions index 5656b482..e54ec8ae 100755 --- a/mmfunctions +++ b/mmfunctions @@ -16,9 +16,11 @@ fi if [[ "$(uname -s)" = "Darwin" ]] ; then FFMPEGFONTPATH='/Library/Fonts/Andale Mono.ttf' XMLSTARLET='xml' -else +elif [[ "$(uname -s)" = "Linux" ]] ; then FFMPEGFONTPATH='/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf' XMLSTARLET='xmlstarlet' +else + echo "Warning: Unsupported system detected. Certain configurations not set. This may cause errors for some scripts." fi _cleanup_mount_dir(){ From 749309e53ac9b55f2e6c6f71400ff945ed7dba02 Mon Sep 17 00:00:00 2001 From: Weaver Date: Tue, 5 Dec 2017 16:22:24 -0800 Subject: [PATCH 5/8] make guidance more explicit --- createmmdb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/createmmdb b/createmmdb index 559f4658..22c6da13 100755 --- a/createmmdb +++ b/createmmdb @@ -84,7 +84,7 @@ echo "Please enter the name of user to be created" read -r USER_NAME echo "Please enter the password for the new user" read -r USER_PASSWORD -echo "Please enter the location of user to be created" +echo "Please enter the location (IP address) of user to be created. To create a user on a locally installed database type: localhost" read -r USER_HOST echo "Please enter mysql root password" mysql_config_editor set --login-path=tempsetting --host=localhost --user=root --password From 81400ebf66843afc3f6c11e75222d18c8c90b46f Mon Sep 17 00:00:00 2001 From: Weaver Date: Fri, 8 Dec 2017 10:29:03 -0800 Subject: [PATCH 6/8] fixes case difference in command --- searchfingerprint | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/searchfingerprint b/searchfingerprint index 142ca3c6..2073a48b 100755 --- a/searchfingerprint +++ b/searchfingerprint @@ -40,8 +40,15 @@ while [ "${*}" != "" ] ; do shift #Confirm input is a video file - if [[ -z $(file -i "${INPUT}" | grep video) ]] ; then - echo "Input is not a video file" && continue + if [[ "$(uname -s)" = Darwin ]] ; then + VIDEOCHECK='file -Ib' + elif [[ "$(uname -s)" = Linux ]] ; then + VIDEOCHECK='file -i' + fi + if ! [[ -z ${VIDEOCHECK} ]] ; then + if [[ -z $(${VIDEOCHECK} "${INPUT}" | grep video) ]] ; then + echo "Input is not a video file" && continue + fi fi IO=$(mktemp) From 115088f3da86103c18d7ff68990346bc3ac04836 Mon Sep 17 00:00:00 2001 From: Weaver Date: Fri, 8 Dec 2017 13:18:57 -0800 Subject: [PATCH 7/8] unset VIDEOCHECK --- searchfingerprint | 1 + 1 file changed, 1 insertion(+) diff --git a/searchfingerprint b/searchfingerprint index 2073a48b..5d519377 100755 --- a/searchfingerprint +++ b/searchfingerprint @@ -40,6 +40,7 @@ while [ "${*}" != "" ] ; do shift #Confirm input is a video file + unset VIDEOCHECK if [[ "$(uname -s)" = Darwin ]] ; then VIDEOCHECK='file -Ib' elif [[ "$(uname -s)" = Linux ]] ; then From f9878b462916fd53cbd134bfe2b348648df7772d Mon Sep 17 00:00:00 2001 From: Weaver Date: Mon, 11 Dec 2017 11:07:43 -0800 Subject: [PATCH 8/8] universalize command --- mmfunctions | 12 +++++------- searchfingerprint | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/mmfunctions b/mmfunctions index e54ec8ae..9d3f66e8 100755 --- a/mmfunctions +++ b/mmfunctions @@ -15,10 +15,8 @@ fi #Setup differences for systems if [[ "$(uname -s)" = "Darwin" ]] ; then FFMPEGFONTPATH='/Library/Fonts/Andale Mono.ttf' - XMLSTARLET='xml' elif [[ "$(uname -s)" = "Linux" ]] ; then FFMPEGFONTPATH='/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf' - XMLSTARLET='xmlstarlet' else echo "Warning: Unsupported system detected. Certain configurations not set. This may cause errors for some scripts." fi @@ -97,7 +95,7 @@ _report_schema_db(){ if [ -z "${xmlschema}" ] ; then xmlschema="$LTO_LOGS/${TAPE_SERIAL}.schema" fi - schema_sorted=$("${XMLSTARLET}" sel -t -m ".//file" -v "concat(name,'|',length, '|', modifytime)" -o "|" -m "ancestor-or-self::directory" -v "name" -o "/" -b -n "${xmlschema}") + schema_sorted=$(xmlstarlet sel -t -m ".//file" -v "concat(name,'|',length, '|', modifytime)" -o "|" -m "ancestor-or-self::directory" -v "name" -o "/" -b -n "${xmlschema}") schema_tape=$(basename "${xmlschema}" | cut -d'.' -f1) IFS=$(echo -en "\n\b") (for i in ${schema_sorted}; do LINE=$i; @@ -247,7 +245,7 @@ _db_error_check(){ } _fingerprint_to_db(){ -VIDEOFINGERPRINT=$("${XMLSTARLET}" sel -N "m=urn:mpeg:mpeg7:schema:2001" -t -m "m:Mpeg7/m:DescriptionUnit/m:Descriptor/m:VideoSignatureRegion/m:VSVideoSegment" -v m:StartFrameOfSegment -o ':' -v m:EndFrameOfSegment -o ':' -m m:BagOfWords -v "translate(.,' ','')" -o ':' -b -n "${FINGERPRINT_XML}") +VIDEOFINGERPRINT=$(xmlstarlet sel -N "m=urn:mpeg:mpeg7:schema:2001" -t -m "m:Mpeg7/m:DescriptionUnit/m:Descriptor/m:VideoSignatureRegion/m:VSVideoSegment" -v m:StartFrameOfSegment -o ':' -v m:EndFrameOfSegment -o ':' -m m:BagOfWords -v "translate(.,' ','')" -o ':' -b -n "${FINGERPRINT_XML}") } _premis_event_list(){ @@ -1002,10 +1000,10 @@ _find_input (){ fi elif [[ "${SOURCEFILE#*.}" = "mkv" ]] ; then # if the sorucefile is an mkv, then check if it has a Presentation Chapter Edition - if [[ -n $(mkvextract tags "${SOURCEFILE}" | "${XMLSTARLET}" sel -t -m "/Tags/Tag/Simple[String='Presentation']" -v String) ]] ; then + if [[ -n $(mkvextract tags "${SOURCEFILE}" | xmlstarlet sel -t -m "/Tags/Tag/Simple[String='Presentation']" -v String) ]] ; then _report -dt "The input file ($(basename "${SOURCEFILE}")) contains a Chapter Edition called 'Presentation', will use that for transcoding." - LISTCHAPTERS=$(mkvextract chapters "${SOURCEFILE}" | "${XMLSTARLET}" sel -t -m Chapters/EditionEntry[EditionFlagDefault='1']/ChapterAtom -v ChapterTimeStart -o "-" -v ChapterTimeEnd -o "-" -v ChapterSegmentUID -n -) - SegmentUIDs=$(mkvextract chapters "${SOURCEFILE}" | "${XMLSTARLET}" sel -t -m Chapters/EditionEntry[EditionFlagDefault='1']/ChapterAtom/ChapterSegmentUID -v . -n | sort -u) + LISTCHAPTERS=$(mkvextract chapters "${SOURCEFILE}" | xmlstarlet sel -t -m Chapters/EditionEntry[EditionFlagDefault='1']/ChapterAtom -v ChapterTimeStart -o "-" -v ChapterTimeEnd -o "-" -v ChapterSegmentUID -n -) + SegmentUIDs=$(mkvextract chapters "${SOURCEFILE}" | xmlstarlet sel -t -m Chapters/EditionEntry[EditionFlagDefault='1']/ChapterAtom/ChapterSegmentUID -v . -n | sort -u) if [[ -n "${LISTCHAPTERS}" ]]; then _report -d "Found this chapter list:" _report -d "${LISTCHAPTERS}" diff --git a/searchfingerprint b/searchfingerprint index 5d519377..702ae412 100755 --- a/searchfingerprint +++ b/searchfingerprint @@ -83,7 +83,7 @@ while [ "${*}" != "" ] ; do #Create Fingerprint ffmpeg -f concat -safe 0 -i "${IO}" -vf signature=format=xml:filename="${TEMPFINGERPRINT}" -map 0:v -f null - - "${XMLSTARLET}" sel -N "m=urn:mpeg:mpeg7:schema:2001" -t -m "m:Mpeg7/m:DescriptionUnit/m:Descriptor/m:VideoSignatureRegion/m:VSVideoSegment" -v m:StartFrameOfSegment -o ':' -v m:EndFrameOfSegment -o ':' -m m:BagOfWords -v "translate(.,' ','')" -o ':' -b -n "${TEMPFINGERPRINT}" > "${TEMPFINGERPRINT_SORTED}" + xmlstarlet sel -N "m=urn:mpeg:mpeg7:schema:2001" -t -m "m:Mpeg7/m:DescriptionUnit/m:Descriptor/m:VideoSignatureRegion/m:VSVideoSegment" -v m:StartFrameOfSegment -o ':' -v m:EndFrameOfSegment -o ':' -m m:BagOfWords -v "translate(.,' ','')" -o ':' -b -n "${TEMPFINGERPRINT}" > "${TEMPFINGERPRINT_SORTED}" #Sort extract relevant values from fingerprint and sort for parsing (IFS=$'\n'