-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathmakemetadata
executable file
·91 lines (75 loc) · 3.55 KB
/
makemetadata
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
# make metadata
#produces errors on zero-sized files
scriptdir=`dirname "$0"`
. "$scriptdir/mmfunctions" || { echo "Missing '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;};
cleanup(){
log -a "Process aborted"
exit 1
}
trap cleanup SIGHUP SIGINT SIGTERM
usage(){
echo
echo "$(basename $0) ${version}"
echo "This script may be run interactively by running it with no arguments or may be used with the following options."
echo "Usage: $(basename $0) [ -m mediaid ]"
echo " -m mediaid"
exit
}
# command-line options to set mediaid and original variables
OPTIND=1
while getopts ":hm:" opt; do
case "$opt" in
h) usage ;;
m) mediaid="$OPTARG" ;;
\?) echo "Invalid option: -$OPTARG" ; exit 1 ;;
:) echo "Option -$OPTARG requires an argument" ; exit 1 ;;
esac
done
shift $(( ${OPTIND} - 1 ))
log -b
counter=0
while [ "$*" != "" ] ; do
uuid=`uuidgen`
cd "$1"
objects_file=`find "./objects" -maxdepth 1 -mindepth 1 -type f -name "*.mov" ! -name ".*"`
service_file=`find "./objects/service" -maxdepth 1 -mindepth 1 -type f -name "*.mov" ! -name ".*"`
mkdir -p "/tmp/$uuid"
outputdir="./metadata/submissionDocumentation/fileMeta"
mkdir -p "$outputdir"
objectbasename=`basename "$objects_file"`
servicebasename=`basename "$service_file"`
mediaid=`basename "$1" | cut -d. -f1`
find "./objects/access" -type d -mindepth 1 -maxdepth 1 > "/tmp/$uuid/access.txt"
while read access ; do
accessname=`basename "$access"`
find "$access" -type f ! -name ".*" > "/tmp/$uuid/access_${accessname}.txt"
while read access_file ; do
mkdir -p "$outputdir/access/$accessname"
accessbasename=`basename "$access_file"`
ffprobe 2>/dev/null "$access_file" -show_format -show_streams -show_data -show_error -show_versions -noprivate -of xml="q=1:x=1" > "$outputdir/access/$accessname/${accessbasename%.*}_ffprobe.xml"
ffprobe 2>/dev/null "$access_file" -show_format -show_streams -show_data -show_error -show_versions -of json > "$outputdir/access/$accessname/${accessbasename%.*}_ffprobe.json"
mediainfo --language=raw -f --output=XML "$access_file" > "$outputdir/access/$accessname/${accessbasename%.*}_mediainfo.xml"
done < "/tmp/$uuid/access_${accessname}.txt"
done < "/tmp/$uuid/access.txt"
outputdir="./metadata/submissionDocumentation/fileMeta"
mkdir -p "$outputdir"
objectbasename=`basename "$objects_file"`
servicebasename=`basename "$service_file"`
mediaid=`basename "$1" | cut -d. -f1`
# transcode
report -dt "STATUS Making metadata reports."
#only works with one file in objects , to do
mkdir -p "$outputdir/objects"
ffprobe 2>/dev/null "$objects_file" -show_format -show_streams -show_data -show_error -show_versions -noprivate -of xml="q=1:x=1" > "$outputdir/objects/${objectbasename%.*}_ffprobe.xml"
ffprobe 2>/dev/null "$objects_file" -show_format -show_streams -show_data -show_error -show_versions -of json > "$outputdir/objects/${objectbasename%.*}_ffprobe.json"
mediainfo --language=raw -f --output=XML "$objects_file" > "$outputdir/objects/${objectbasename%.*}_mediainfo.xml"
mkdir -p "$outputdir/service"
ffprobe 2>/dev/null "$service_file" -show_format -show_streams -show_data -show_error -show_versions -noprivate -of xml="q=1:x=1" > "$outputdir/service/${servicebasename%.*}_ffprobe.xml"
ffprobe 2>/dev/null "$service_file" -show_format -show_streams -show_data -show_error -show_versions -of json > "$outputdir/service/${servicebasename%.*}_ffprobe.json"
mediainfo --language=raw -f --output=XML "$service_file" > "$outputdir/service/${servicebasename%.*}_mediainfo.xml"
rm -r -f "/tmp/$uuid"
shift
counter=`expr "$counter" + 1`
done
log -e