forked from mediamicroservices/mm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefingerprint
executable file
·44 lines (41 loc) · 1.62 KB
/
makefingerprint
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# makefingerprint generates a video perceptual hash for an input
SCRIPTDIR=$(dirname $(which "${0}"))
. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;};
SUFFIX="_signature"
EXTENSION="xml"
RELATIVEPATH="metadata"
while [ "${*}" != "" ] ; do
# get context about the input
INPUT="${1}"
shift
if [ -z "${OUTPUTDIR_FORCED}" ] ; then
[ -d "${INPUT}" ] && { OUTPUTDIR="$INPUT/metadata/${RELATIVEPATH}" && FINGERDIR="${INPUT}/metadata/fingerprints" ;};
[ -f "${INPUT}" ] && { OUTPUTDIR=$(dirname "${INPUT}")"/${RELATIVEPATH}" && FINGERDIR="$(dirname "${INPUT}")/fingerprints" ;};
[ ! "${OUTPUTDIR}" ] && { OUTPUTDIR="${INPUT}/metadata/${RELATIVEPATH}" && FINGERDIR="${INPUT}/metadata/fingerprints" ;};
else
OUTPUTDIR="${OUTPUTDIR_FORCED}"
FINGERDIR="${OUTPUTDIR}/metadata/fingerprints"
fi
_unset_variables
PREFERRED_SOURCE="service"
_find_input "${INPUT}"
MEDIAID=$(basename "${INPUT}" | cut -d. -f1)
if [ "${FINGERDIR}" != "" ] ; then
_mkdir2 "${FINGERDIR}"
fi
#Generate Fingerprint
SIGNATURE="${MEDIAID}""${SUFFIX}"."${EXTENSION}"
_run_critical_event ffmpeg "${FFMPEGINPUT[@]}" -vf signature=format=xml:filename="${FINGERDIR}/${SIGNATURE}" -map 0:v -f null -
FINGERPRINT_XML="${FINGERDIR}/${SIGNATURE}"
#Report to DB
if [ "${PERCEPTUAL_HASH}" = "1" ] && [ "${PREMIS_DB}" = "Y" ]; then
_fingerprint_to_db
_report_to_db
_report_fingerprint_db
_eventoutcome_update
gzip "${FINGERPRINT_XML}"
else
gzip "${FINGERPRINT_XML}"
fi
done