This repository has been archived by the owner on Jan 8, 2025. It is now read-only.
forked from Tasssadar/bugfree-tribble
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecord_cam.sh
executable file
·105 lines (95 loc) · 2.5 KB
/
record_cam.sh
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
#!/bin/sh
DEST=""
DEV="/dev/video1"
RES="1280x720"
FPS="30"
LED="auto"
ROTATE="0"
FOCUS="auto"
for a in $@; do
case $a in
-h|--help)
echo "TODO"
exit 0
;;
--dev=*)
DEV="${a#--dev=}"
;;
--res=*)
RES="${a#--res=}"
;;
--fps=*)
FPS="${a#--fps=}"
;;
--led=*)
LED="${a#--led=}"
;;
--rotate=*)
ROTATE="${a#--rotate=}"
;;
--soc)
ROTATE="90"
LED="off"
FOCUS="25"
;;
*)
DEST="$a"
;;
esac
done
res_w="${RES%x*}"
res_h="${RES#*x}"
lib="$LD_LIBRARY_PATH"
if [ -z "${lib##*/usr/local/lib*}" ]; then
lib="${lib}:/usr/local/lib"
fi
echo "Disabling exposure priority"
v4l2-ctl -d ${DEV} -c exposure_auto_priority=0
led_val="3"
case $LED in
off)
led_val="0"
;;
on)
led_val="1"
;;
blink)
led_val="2"
;;
*)
led_val="3"
;;
esac
echo "Setting LED to $LED ($led_val)"
v4l2-ctl -d ${DEV} -c led1_mode=$led_val
rotate_cmd_part=""
case $ROTATE in
0)
;;
90)
rotate_cmd_part="! videoflip method=clockwise"
;;
180)
rotate_cmd_part="! videoflip method=rotate-180"
;;
270)
rotate_cmd_part="! videoflip method=counterclockwise"
;;
esac
case $FOCUS in
auto)
v4l2-ctl -d ${DEV} -c focus_auto=1
;;
*)
v4l2-ctl -d ${DEV} -c focus_auto=0
v4l2-ctl -d ${DEV} -c focus_absolute=${FOCUS}
;;
esac
if [ -n "$DEST" ]; then
LD_LIBRARY_PATH="$lib" gst-launch -ev uvch264_src device=${DEV} name=src auto-start=true src.vfsrc ! queue ! video/x-raw-yuv,width=640,height=480,framerate=30/1 ${rotate_cmd_part} ! timeoverlay auto-resize=false ! xvimagesink sync=false \
src.vidsrc ! queue ! video/x-h264,width=${res_w},height=${res_h},framerate=${FPS}/1,profile=high ! stamp sync-margin=2 ! h264parse ! queue ! ffmux_mp4 name=mux ! filesink location=\"${DEST}\" sync=true \
alsasrc device="plughw:1,0" ! audio/x-raw-int,rate=44100,channels=2,depth=32 ! queue ! audioconvert ! queue ! faac ! queue ! mux.
else
LD_LIBRARY_PATH="$lib" gst-launch -e uvch264_src device=${DEV} name=src auto-start=true src.vidsrc ! queue ! video/x-h264,width=${res_w},height=${res_h},framerate=${FPS}/1,profile=high ! \
h264parse ! ffdec_h264 ${rotate_cmd_part} ! xvimagesink force-aspect-ratio=true
fi