544ef0651f8943e27aebfe85385517586fe110f2
[experiments/gstreamer.git] / shell / ges-cut-clip.sh
1 #!/bin/sh
2
3 set -e
4
5 usage() {
6   echo "usage: $(basename $0) <input> <inpoint in HH:MM:SS> <duration in HH:MM:SS> <output>"
7 }
8
9 [ -f "$1" ] || { usage 1>&2; exit 1; }
10 INPUT_FILE="$1"
11
12 read INPOINT_HH INPOINT_MM INPOINT_SS <<< ${2//:/ }
13 read DURATION_HH DURATION_MM DURATION_SS <<< ${3//:/ }
14
15 # Remove leading zeros before performing the multiplications
16 INPOINT=$((${INPOINT_HH#0} * 60 * 60 + ${INPOINT_MM#0} * 60 + ${INPOINT_SS#0}))
17 DURATION=$((${DURATION_HH#0} * 60 * 60 + ${DURATION_MM#0} * 60 + ${DURATION_SS#0}))
18
19 [ -e "$4" ] && { echo "Output file already exists, bailing out!" 1>&2; exit 1; }
20 OUTPUT_FILE="$4"
21
22 ges-launch-1.0 +clip "$INPUT_FILE" inpoint=$INPOINT duration=$DURATION -o "$OUTPUT_FILE"