forked from mediamicroservices/mm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blackatends
executable file
·46 lines (41 loc) · 1.34 KB
/
blackatends
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
#!/bin/bash
# blackatends
# Accepts one or many video files as an input and determines how many frames of black are at the beginning and at the end
SCRIPTDIR=$(dirname "${0}")
. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;};
VERSION=1.0
_cleanup(){
_log -a "Process aborted"
exit 1
}
trap _cleanup SIGHUP SIGINT SIGTERM
_usage(){
echo
echo "$(basename "${0}") ${VERSION}"
echo "This program will report on the number of black frames at the beginning and end of a video file."
echo
echo "Usage: $(basename ${0}) file1 [ file2 ... ]"
echo
echo "Options:"
echo " -h display this help"
echo
exit
}
[ "${#}" = 0 ] && _usage
# command-line options for help and invalid options
OPTIND=1
while getopts ":h" OPT; do
case "${OPT}" in
h) _usage ;;
\?) echo "Invalid option: -${OPTARG}" ; _writeerrorlog "blackatends" "You used an invalid option and the script had to exit" ; exit 1 ;;
:) echo "Option -${OPTARG} requires an argument" ; _writeerrorlog "blackatends" "The option selected required an argument and none was provided. The script had to exit." ; exit 1 ;;
esac
done
shift $(( ${OPTIND} - 1 ))
while [ "${*}" != "" ] ; do
_log -b
[ "${#}" != 0 ] && SOURCEFILE="${1}"
_black_at_ends "${SOURCEFILE}"
_log -e
shift
done