-
Notifications
You must be signed in to change notification settings - Fork 27
/
migratexdcam
executable file
·152 lines (131 loc) · 5.55 KB
/
migratexdcam
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/bash
# migratexdcam
# Transfer data from XDCAM disc
SCRIPTDIR=$(dirname "${0}")
. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;};
_cleanup(){
_log -a "Process aborted"
exit 1
}
trap _cleanup SIGHUP SIGINT SIGTERM
_log -b
_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}) [ -c output_directory_for_xdcam ]"
echo " -c output_directory_for_xdcam (else will default to ${MM_CONFIG_FILE})"
exit
}
# command-line options to set mediaid and original variables
OPTIND=1
while getopts ":hc:" OPT; do
case "${OPT}" in
h) _usage ;;
c) OUTDIR_INGESTXDCAM="${OPTARG}" ;;
\?) _report -w "Invalid option: -${OPTARG}" ; exit 1 ;;
:) _report -w "Option -${OPTARG} requires an argument" ; _writeerrorlog "xdcamingest" "The option selected required an argument and none was provided. The script had to exit." ; exit 1 ;;
esac
done
if [ ! -d "${OUTDIR_INGESTXDCAM}" ] ; then
_report -w "The XDCam processing directory must be set. Use [ -c /path/to/XDCam/processing/directory ]."
exit 1
fi
#Interview the operator
_report -qn "Please enter a valid Media ID. If there is no Media ID, please enter the Format Identifier: "
read -e MEDIAID
if [ "${MEDIAID}" == "q" ]; then
exit 0
fi
_report -qn "Please enter a Format Identifier: "
read -e FORMATID
if [ "${FORMATID}" == "q" ]; then
exit 0
fi
_report -qn "Please enter any information from the disc's paper label: "
read -e LABELINPUT
if [ "${LABELINPUT}" == "q" ]; then
exit 0
fi
_report -qn "Oh...I didn't get your name! Would you mind entering it here and I'll include it in the record: "
read -e OP
if [ "${OP}" == "q" ]; then
exit 0
fi
_report -qn "Please load the disk and press enter once the directory appears in Finder, or enter q to quit."
read -e WAIT
if [ "${WAIT}" == "q" ]; then
exit 0
fi
#Pick deck of multiple.
VOLUME_ARRAY=($(find /Volumes -name "XDCAM*" -maxdepth 1 | sort))
_report -d "Let's get started!"
echo "Select the deck you'd like to use:"
PS3="Which XDCAM deck?"
select XDCAM_VOLUME in "${VOLUME_ARRAY[@]}" ; do
break
done
if [ ! "${XDCAM_VOLUME}" ] ; then
echo "Error: You selected an invalid option."
exit 1
fi
echo "You picked ${XDCAM_VOLUME}"
XDCAM_MOUNT="${XDCAM_VOLUME}"
DECK1=$(basename "${XDCAM_MOUNT}")
_report -dt "We're almost ready to begin transfer. I found the XDCAM deck: ${DECK1}"
#report results of OP interview
MEDIAID="${MEDIAID}"
FORMATID="${FORMATID}"
DEVICEID1="${XDCAM_VOLUME}"
echo ----------------------------------
echo XDCAM Deck is: "${XDCAM_VOLUME}"
echo Media ID is: "${MEDIAID}"
echo Format Identifier is: "${FORMATID}"
echo The label reads: "${LABELINPUT}"
echo Your name is: "${OP}"
echo ----------------------------------
PS3="Do these values look correct? "
eval set "'Yes' 'No'"
select OPTION in "${@}"
do
break
done
if [ "${OPTION}" != "Yes" ] ; then
echo Start Over
echo
else
# check for existing output
if [ -d "${OUTDIR_INGESTXDCAM}/${MEDIAID}" ] ; then
_report -dt "It looks like ${MEDIAID} was already ingested. These things happen! If you want to overwrite the existing one please just delete ${OUTDIR_INGESTXDCAM}/${MEDIAID} first and then try again."
else
#create ingest log file and directory
mkdir -p "${OUTDIR_INGESTXDCAM}/${MEDIAID}/metadata/logs"
INGESTLOG="${OUTDIR_INGESTXDCAM}/${MEDIAID}/metadata/logs/capture.log"
_writeingestlog "media ID" "${MEDIAID}"
_writeingestlog "disc label info" "${LABELINPUT}"
_writeingestlog "operator" "${OP}"
_writeingestlog "ingest_process_dir" "${OUTDIR_INGESTXDCAM}"
_writeingestlog "datetime_start" "$(_get_iso8601)"
# start xdcam ingest process
START=$(date -u "+%Y%m%dT%H%M%SZ")
mkdir -p "${OUTDIR_INGESTXDCAM}/${MEDIAID}/objects"
_report -dt "migrating video..."
rsync -rtv --stats --progress --log-file="${OUTDIR_INGESTXDCAM}/${MEDIAID}/metadata/logs/rsync_$(_get_iso8601_c)_$(basename $0)_${VERSION}.txt" "/Volumes/${DECK1}/Clip/" "${OUTDIR_INGESTXDCAM}/${MEDIAID}/objects/"
diskutil info "${XDCAM_MOUNT}" > "${OUTDIR_INGESTXDCAM}/${MEDIAID}/metadata/logs/diskutilinfo.log"
end=$(date -u "+%Y%m%dT%H%M%SZ")
hdiutil eject "/Volumes/${DECK1}"
mv -v -n "${OUTDIR_INGESTXDCAM}/${MEDIAID}/objects/"*.XML "${OUTDIR_INGESTXDCAM}/${MEDIAID}/metadata/logs/"
_writeingestlog "datetime_end" "$(_get_iso8601)"
#rename files
for FILE in $(find "${OUTDIR_INGESTXDCAM}/${MEDIAID}/objects" -iname "*.MXF" -type f | sort) ; do
MXFNAME="$(basename "${FILE}")"
MXFDIR="$(dirname "${FILE}")"
NEWNAME="${MXFDIR}/${FORMATID}-${MXFNAME}"
mv -v -n "${FILE}" "${NEWNAME}"
done
echo "-----------------------------------------------------------"
_report -d "All done! Don't forget to grab your disc from the machine!"
echo "-----------------------------------------------------------"
fi
fi
_log -e