forked from dericed/framemd5cmp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeframemd5
executable file
·97 lines (88 loc) · 3.56 KB
/
makeframemd5
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
#!/bin/bash
# makeframemd5
version="1.0"
unset dependencies
dependencies=(ffmpeg ffprobe)
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) [ -i input ] [ -d ] [ -c ] [ -f ]"
echo " -h Show this 'help'."
echo " -d Decode video frames prior to checksuming."
echo " -c Copy video frames to checksum utility"
echo " -f (experimental) Fingerprint video frames by filter frames to "
exit
}
check_dependencies(){
deps_ok=YES
while [ "$*" != "" ] ; do
dependency="$1"
if [ ! $(which $dependency) ] ; then
echo "This script requires $dependency to run but it is not installed"
echo "If you are running ubuntu or debian you might be able to install $dependency with the following command"
echo "sudo apt-get install ${dependency}"
echo "If you are running mac you might be able to install $dependency with the following command"
echo "brew install ${dependency}"
deps_ok=NO
fi
shift
done
if [[ "$deps_ok" == "NO" ]]; then
echo "Unmet dependencies"
echo "Aborting!"
exit 1
else
return 0
fi
}
check_dependencies "${dependencies[@]}"
unset framemd5opts
while getopts ":i:dcf" opt; do
case "$opt" in
i) input="$OPTARG"
[ -d "$input" ] && { outputdir="$input/metadata/submissionDocumentation/framemd5" && logdir="$input/metadata/submissionDocumentation/framemd5/logs" ;};
[ -f "$input" ] && { outputdir=`dirname "$input"`"/framemd5" && logdir="`dirname "$input"`/framemd5/logs" ;}; ;;
h) usage ;;
d) outputname="$outputdir"/$(basename "${input%.*}_framemd5.md5")
if [ ! -f "$outputname" ] ; then
framemd5opts+=(-f framemd5 -an "$outputname")
else
echo "$outputname already exists skipping."
fi ;;
c) outputname="$outputdir"/$(basename "${input%.*}_codec_copy_framemd5.md5")
if [ ! -f "$outputname" ] ; then
framemd5opts+=(-c copy -an -f framemd5 "$outputname")
else
echo "$outputname already exists skipping."
fi ;;
f) outputname="$outputdir"/$(basename "${input%.*}_monow_sqcif_framemd5.md5")
if [ ! -f "$outputname" ] ; then
framemd5opts+=(-vf format=monow,scale=40:30 -an -f framemd5 "$outputname")
else
echo "$outputname already exists skipping."
fi ;;
\?) echo "Invalid option: -$OPTARG" ; exit 1 ;;
:) echo "Option -$OPTARG requires an argument" ; exit 1 ;;
esac
done
shift $(( ${OPTIND} - 1 ))
[ "${input}" = "" ] && { echo -e "An input must be given as in\n $(basename $0) [ -i input ]" ; exit 1 ;};
[ ! -f "$input" ] && { echo "Sorry, the input must be a file (for now)." ; exit 1 ;};
if [[ "${framemd5opts}" -eq "" ]] ; then
outputname="$outputdir"/$(basename "${input%.*}_framemd5.md5")
framemd5opts+=(-f framemd5 -an "$outputname")
fi
mkdir -p "${outputdir}"
if [ "${logdir}" != "" ] ; then
mkdir -p "${logdir}"
export FFREPORT="file=${logdir}/$(basename ${input%.*})_%p_%t_$(basename $0)_${version}.txt"
inputoptions+=(-vsync passthrough -v warning -stats)
fi
echo "Running: ffmpeg ${inputoptions[@]} -i ${input} ${framemd5opts[@]}"
ffmpeg ${inputoptions[@]} -i ${input} ${framemd5opts[@]}