-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcutter.sh
More file actions
executable file
·36 lines (31 loc) · 1.14 KB
/
cutter.sh
File metadata and controls
executable file
·36 lines (31 loc) · 1.14 KB
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
#!/bin/bash
# #!/bin/sh
# #!/usr/bin/env sh
ext=${1##*.}
vidname=0
fps=`ffmpeg -i $1 2>&1 | sed -n "s/.*, \(.*\) fp.*/\1/p"`
frame=$(echo "0/$fps" | bc -l | sed 's/^\./0\./')
framecount=$(ffmpeg -i $1 -map 0:v:0 -c copy -f null - 2>&1 | \
grep frame | sed -e 's/frame=\W*\([0-9]*\).*/\1/')
echo Framecount: $framecount 1>&2
tempdir=$(mktemp -d tmpvids.XXXXXX)
trap 'rm -rf "$tempdir"' 0 1 2 9 15
./handrecog $1 | \
while read fr event gest; do
[ -n "$fr" ] || continue
echo $fr $event $gest "$(echo $fr/$fps | bc)s"
if [ "$event" == 'end' ]; then
frame=$fr
elif [ "$gest" == 'up' ]; then
#echo $frame $fr $fps
s=$(echo "$frame/$fps" | bc -l | sed 's/^\./0\./')
e=$(echo "$fr /$fps" | bc -l | sed 's/^\./0\./')
#echo $s $e
ffmpeg -nostdin -y -i $1 -ss $s -to $e $tempdir/$vidname.$ext 2>/dev/null
echo "file '$vidname.$ext'" >> $tempdir/filelist.txt
vidname=$((vidname+1))
fi
done
ffmpeg -nostdin -y -f concat -i $tempdir/filelist.txt -c copy $1 2>/dev/null
# ffmpeg -nostdin -y -f concat -i $tempdir/filelist.txt -c copy "/app/test2.mp4" 2>/dev/null
# chmod a+wx "$1"