Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux tweaks #206

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion createmmdb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 14 additions & 5 deletions mmfunctions
Original file line number Diff line number Diff line change
Expand Up @@ -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'
elif [[ "$(uname -s)" = "Linux" ]] ; then
FFMPEGFONTPATH='/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf'
else
echo "Warning: Unsupported system detected. Certain configurations not set. This may cause errors for some scripts."
fi

_cleanup_mount_dir(){
if [ -d "${MOUNT_DIR}" ] ; then
echo calling umount
Expand Down Expand Up @@ -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 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;
Expand Down Expand Up @@ -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 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(){
Expand Down Expand Up @@ -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 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}" | 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 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}"
Expand Down
16 changes: 12 additions & 4 deletions searchfingerprint
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,16 @@ while [ "${*}" != "" ] ; do
shift

#Confirm input is a video file
if [[ -z $(file -Ib "${INPUT}" | grep video) ]] ; then
echo "Input is not a video file" && continue
unset VIDEOCHECK
if [[ "$(uname -s)" = Darwin ]] ; then
VIDEOCHECK='file -Ib'
elif [[ "$(uname -s)" = Linux ]] ; then
VIDEOCHECK='file -i'
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add also here an

else

with a warning or an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is just a check to see if the input is a video (and throw an error if it isn't) I thought it would be better to attempt to set the variable, but then to skip the video check if the variable was unset (See line 48).

This way, if the person was using an irregular system (but somehow everything else was working) with a valid input it would allow them to proceed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand. Would in this case an

unset VIDEOCHECK

before the line 43 be appropriate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point! I'll add that in!

if ! [[ -z ${VIDEOCHECK} ]] ; then
if [[ -z $(${VIDEOCHECK} "${INPUT}" | grep video) ]] ; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on mac running:
VIDEOCHECK='file -Ib' ; $(${VIDEOCHECK} /Users/daverice/Desktop/test5_prores.mov)

I get
-bash: video/quicktime;: No such file or directory

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't that because it is using command substitution and attempting to run the output of $(${VIDEOCHECK} /Users/daverice/Desktop/test5_prores.mov) as a command?

In the same way that just running $(echo "hello") will also throw an error as it attempts to execute hello?

On my end, using the command VIDEOCHECK='file -i' ; $(${VIDEOCHECK} input.mov) will also throw an error, but within the context of the script, or even something like VIDEOCHECK='file -i' ; var=$(${VIDEOCHECK} input.mov) ; echo "${var}" gives the expected output/behavior.

echo "Input is not a video file" && continue
fi
fi

IO=$(mktemp)
Expand Down Expand Up @@ -75,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 -
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'
Expand Down Expand Up @@ -174,5 +182,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:[email protected]: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:[email protected]:fontsize=20:fontfile="${FFMPEGFONTPATH}":textfile="${DRAWTEXT}"
fi