forked from m6c7l/gopro-console
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgopro-hero3p-se.sh
executable file
·754 lines (664 loc) · 11 KB
/
gopro-hero3p-se.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
#!/bin/bash
#
# Copyright (c) 2016, Manfred Constapel
# This file is licensed under the terms of the MIT license.
#
RED='\033[0;41;30m'
STD='\033[0;0;39m'
# CONTROL : LOCATE
llMenu() {
clear
echo -e "\n Locate\n"
echo " 1. On"
echo " 2. Off"
echo
echo -e " 0. Return\n"
}
ll() {
CMD="LL"
local choice
llMenu
read -p " > " choice
case ${choice} in
1) OPT="01"; command ;;
2) OPT="00"; command ;;
0) ;;
*) invalid; ll ;;
esac
}
# CONTROL : RECORDING
pwMenu() {
clear
echo -e "\n Power\n"
echo " 1. On"
echo " 2. Off"
echo
echo -e " 0. Return\n"
}
pw() {
APP="bacpac"
CMD="PW"
local choice
pwMenu
read -p " > " choice
case ${choice} in
1) OPT="01"; command ;;
2) OPT="00"; command ;;
0) ;;
*) invalid; pw ;;
esac
APP="camera"
}
# CONTROL : RECORDING
shMenu() {
clear
echo -e "\n Recording\n"
echo " 1. Start"
echo " 2. Stop"
echo
echo -e " 0. Return\n"
}
sh() {
CMD="SH"
local choice
shMenu
read -p " > " choice
case ${choice} in
1) OPT="01"; command ;;
2) OPT="00"; command ;;
0) ;;
*) invalid; sh ;;
esac
}
# CONTROL
controlMenu() {
clear
echo -e "\n Control\n"
echo " 1. Recording"
echo " 2. Power"
echo " 3. Locate"
echo
echo -e " 0. Return\n"
}
control() {
local choice
while true; do
controlMenu
read -p " > " choice
case ${choice} in
1) sh ;;
2) pw ;;
3) ll ;;
0) break ;;
*) invalid ;;
esac
done
}
# DELETE : DELETE LAST FILE
dl() {
read -p " > Execute? [yn] " choice
case ${choice} in
y) CMD="DL"; OPT=""; command ;;
esac
}
# DELETE : DELETE ALL FILES FROM SD CARD
da() {
read -p " > Execute? [yn] " choice
case ${choice} in
y) CMD="DA"; OPT=""; command ;;
esac
}
# DELETE
deleteMenu() {
clear
echo -e "\n Delete\n"
echo " 1. Delete Last File"
echo " 2. Delete all Files from SD Card"
echo
echo -e " 0. Return\n"
}
delete() {
local choice
while true; do
deleteMenu
read -p " > " choice
case ${choice} in
1) dl ;;
2) da ;;
0) break ;;
*) invalid ;;
esac
done
}
# SETUP : MODE
cmMenu() {
clear
echo -e "\n Mode\n"
echo " 1. Video"
echo " 2. Still"
echo " 3. Burst"
echo " 4. Time Lapse"
echo " 5. HDMI"
echo
echo -e " 0. Return\n"
}
cm() {
CMD="CM"
local choice
cmMenu
read -p " > " choice
case ${choice} in
1) OPT="00"; command ;;
2) OPT="01"; command ;;
3) OPT="02"; command ;;
4) OPT="03"; command ;;
5) OPT="05"; command ;;
0) ;;
*) invalid; cm ;;
esac
}
# SETUP : SET DATE AND TIME
tm() {
echo
echo -n " Not implemented yet. "
pause
}
# SETUP : NTSC/PAL
vmMenu() {
clear
echo -e "\n Video Region\n"
echo " 1. NTSC"
echo " 2. PAL"
echo
echo -e " 0. Return\n"
}
vm() {
CMD="VM"
local choice
vmMenu
read -p " > " choice
case ${choice} in
1) OPT="00"; command ;;
2) OPT="01"; command ;;
0) ;;
*) invalid; vm ;;
esac
}
# SETUP : DEFAULT AT POWER UP
dmMenu() {
clear
echo -e "\n Default at Power Up\n"
echo " 1. Video"
echo " 2. Photo"
echo " 3. Burst"
echo " 4. Time Lapse"
echo
echo -e " 0. Return\n"
}
dm() {
CMD="DM"
local choice
dmMenu
read -p " > " choice
case ${choice} in
1) OPT="00"; command ;;
2) OPT="01"; command ;;
3) OPT="02"; command ;;
4) OPT="03"; command ;;
0) ;;
*) invalid; dm ;;
esac
}
# SETUP : BEEP
bsMenu() {
clear
echo -e "\n Beep\n"
echo " 1. Off"
echo " 2. 70%"
echo " 3. 100%"
echo
echo -e " 0. Return\n"
}
bs() {
CMD="BS"
local choice
bsMenu
read -p " > " choice
case ${choice} in
1) OPT="00"; command ;;
2) OPT="01"; command ;;
3) OPT="02"; command ;;
0) ;;
*) invalid; bs ;;
esac
}
# SETUP : LED
lbMenu() {
clear
echo -e "\n LED\n"
echo " 1. Off"
echo " 2. 2"
echo " 3. 4"
echo
echo -e " 0. Return\n"
}
lb() {
CMD="LB"
local choice
lbMenu
read -p " > " choice
case ${choice} in
1) OPT="00"; command ;;
2) OPT="01"; command ;;
3) OPT="02"; command ;;
0) ;;
*) invalid; lb ;;
esac
}
# SETUP
setupMenu() {
clear
echo -e "\n Setup\n"
echo " 1. LED"
echo " 2. Beep"
echo " 3. Default at Power Up"
echo " 4. Video Region"
echo " 5. Set Date and Time"
echo " 6. Mode"
echo
echo -e " 0. Return\n"
}
setup() {
local choice
while true; do
setupMenu
read -p " > " choice
case ${choice} in
1) lb ;;
2) bs ;;
3) dm ;;
4) vm ;;
5) tm ;;
6) cm ;;
0) break ;;
*) invalid ;;
esac
done
}
# CAPTURE SETTINGS : LOOPING VIDEO
loMenu() {
clear
echo -e "\n Looping Video\n"
echo " 1. Off"
echo " 2. 5 min"
echo " 3. 20 min"
echo " 4. 60 min"
echo " 5. 120 min"
echo " 6. Max"
echo
echo -e " 0. Return\n"
}
lo() {
CMD="LO"
local choice
loMenu
read -p " > " choice
case ${choice} in
1) OPT="00"; command ;;
2) OPT="01"; command ;;
3) OPT="02"; command ;;
4) OPT="03"; command ;;
5) OPT="04"; command ;;
6) OPT="05"; command ;;
0) ;;
*) invalid; lo ;;
esac
}
# CAPTURE SETTINGS : SPOT METER
exMenu() {
clear
echo -e "\n Spot Meter\n"
echo " 1. On"
echo " 2. Off"
echo
echo -e " 0. Return\n"
}
ex() {
CMD="EX"
local choice
exMenu
read -p " > " choice
case ${choice} in
1) OPT="01"; command ;;
2) OPT="00"; command ;;
0) ;;
*) invalid; ex ;;
esac
}
# CAPTURE SETTINGS : UPSIDE DOWN
upMenu() {
clear
echo -e "\n Upside Down\n"
echo " 1. On"
echo " 2. Off"
echo
echo -e " 0. Return\n"
}
up() {
CMD="UP"
local choice
upMenu
read -p " > " choice
case ${choice} in
1) OPT="01"; command ;;
2) OPT="00"; command ;;
0) ;;
*) invalid; up ;;
esac
}
# CAPTURE SETTINGS
captureMenu() {
clear
echo -e "\n Capture Settings\n"
echo " 1. Upside Down"
echo " 2. Spot Meter"
echo " 3. Looping"
echo
echo -e " 0. Return\n"
}
capture() {
local choice
while true; do
captureMenu
read -p " > " choice
case ${choice} in
1) up ;;
2) ex ;;
3) lo ;;
0) break ;;
*) invalid ;;
esac
done
}
# CAMERA SETTINGS : VIDEO RESOLUTION
vvMenu() {
clear
echo -e "\n Video Resolution\n"
echo " 1. 1080"
echo " 2. 960"
echo " 3. 720"
echo " 4. WVGA"
echo
echo -e " 0. Return\n"
}
vv() {
CMD="VV"
local choice
vvMenu
read -p " > " choice
case ${choice} in
1) OPT="03"; command ;;
2) OPT="02"; command ;;
3) OPT="01"; command ;;
4) OPT="00"; command ;;
0) ;;
*) invalid; vv ;;
esac
}
# CAMERA SETTINGS : FRAME RATE
fsMenu() {
clear
echo -e "\n NTSC/PAL Frame Rate (Video Resolutions)\n"
echo " 1. 30/ 25 (1080, 960, 720, )"
echo " 2. 60/ 50 (1080, 960, 720, WVGA)"
echo " 3. 120/100 ( 720, WVGA)"
echo
echo -e " 0. Return\n"
}
fs() {
CMD="FS"
local choice
fsMenu
read -p " > " choice
case ${choice} in
1) OPT="04"; command ;;
2) OPT="07"; command ;;
3) OPT="09"; command ;;
0) ;;
*) invalid; fs ;;
esac
}
# CAMERA SETTINGS : FIELD OF VIEW
fvMenu() {
clear
echo -e "\n Field of View\n"
echo " 1. Wide (1080, 960, 720, WVGA)"
echo " 2. Medium (1080, 720, )"
echo " 3. Narrow (1080, 720, )"
echo
echo -e " 0. Return\n"
}
fv() {
CMD="FV"
local choice
fvMenu
read -p " > " choice
case ${choice} in
1) OPT="00"; command ;;
2) OPT="01"; command ;;
3) OPT="02"; command ;;
0) ;;
*) invalid; fv ;;
esac
}
# CAMERA SETTINGS : PHOTO RESOLUTION
prMenu() {
clear
echo -e "\n Photo Resolution\n"
echo " 1. 10 MP"
echo " 2. 7 MP"
echo " 3. 5 MP"
echo
echo -e " 0. Return\n"
}
pr() {
CMD="PR"
local choice
prMenu
read -p " > " choice
case ${choice} in
1) OPT="08"; command ;;
2) OPT="04"; command ;;
3) OPT="03"; command ;;
0) ;;
*) invalid; pr ;;
esac
}
# CAMERA SETTINGS : BURST RATE
buMenu() {
clear
echo -e "\n Burst Rate\n"
echo " 1. 3/1s"
echo " 2. 5/1s"
echo " 3. 10/1s"
echo
echo -e " 0. Return\n"
}
bu() {
CMD="BU"
local choice
buMenu
read -p " > " choice
case ${choice} in
1) OPT="00"; command ;;
2) OPT="01"; command ;;
3) OPT="02"; command ;;
0) ;;
*) invalid; bu ;;
esac
}
# CAMERA SETTINGS : TIME LAPSE
tiMenu() {
clear
echo -e "\n Time Lapse\n"
echo " 1. 0.5s"
echo " 2. 1s"
echo " 3. 2s"
echo " 4. 5s"
echo " 5. 10s"
echo " 6. 30s"
echo " 7. 60s"
echo
echo -e " 0. Return\n"
}
ti() {
CMD="TI"
local choice
tiMenu
read -p " > " choice
case ${choice} in
1) OPT="00"; command ;;
2) OPT="01"; command ;;
3) OPT="02"; command ;;
4) OPT="05"; command ;;
5) OPT="0A"; command ;;
6) OPT="1E"; command ;;
7) OPT="3C"; command ;;
0) ;;
*) invalid; ti ;;
esac
}
# CAMERA SETTINGS
cameraMenu() {
clear
echo -e "\n Camera Settings\n"
echo " 1. Video Resolution"
echo " 2. Frame Rate"
echo " 3. Field of View"
echo " 4. Photo Resolution"
echo " 5. Burst Rate"
echo " 6. Time Lapse"
echo
echo -e " 0. Return\n"
}
camera() {
local choice
while true; do
cameraMenu
read -p " > " choice
case ${choice} in
1) vv ;;
2) fs ;;
3) fv ;;
4) pr ;;
5) bu ;;
6) ti ;;
0) break ;;
*) invalid ;;
esac
done
}
# MAIN
gpMediaList() {
echo
echo -ne $(curl -s -m 2 "http://10.5.5.9:8080/gp/gpMediaList") | \
sed -e "s/\[{/\[{\n/g" | \
sed -e "s/\,{/,{\n/g" | \
sed -e "s/\"d\"/ \"d\"/g" | \
sed -e "s/\"n\"/ \"n\"/g"
read -rsp $'' -n1 key
}
cv() {
echo
echo -ne $(curl -s -m 2 "http://10.5.5.9/camera/cv") | \
sed -e "s/[\o0\o1\o2\o3\o4\o5\o6\o7\o10]//g" | \
sed -e "s/[\o25]/\n/g" | \
sed -e 's/^[[:space:]]*//'
echo
echo
echo -ne $(curl -s -m 2 "http://10.5.5.9/bacpac/cv") | \
sed -e "s/[\o0\o1\o2\o3\o4\o5\o6\o7\o10]//g" | \
sed -e "s/[\o25]/\n/g" | \
sed -e 's/^[[:space:]]*//'
read -rsp $'' -n1 key
}
mainMenu() {
clear
echo -e "\n GoPro HERO3+ Silver Edition\n"
echo " 1. Camera Settings"
echo " 2. Capture Settings"
echo " 3. Setup"
echo " 4. Delete"
echo " 6. Info"
echo " 7. Media List"
echo " 8. Control"
echo " 9. Preview"
echo
echo -e " 0. Exit\n"
}
main() {
APP="camera"
local choice
while true; do
mainMenu
read -p " > " choice
case ${choice} in
1) camera ;;
2) capture ;;
3) setup ;;
4) delete ;;
6) cv ;;
7) gpMediaList ;;
8) control ;;
9) preview ;;
0) exit 0 ;;
*) invalid ;;
esac
done
}
command() {
PARA=""
if [[ -n ${OPT} ]]; then
PARA="&p=%"${OPT}
fi
echo -ne $(curl -s -m 2 "http://10.5.5.9/${APP}/${CMD}?t=${PASS}${PARA}") | \
sed -e "s/[\o0\o1\o2\o3\o4\o5\o6\o7\o10]//g" | \
sed -e "s/[\o25]/\n/g" | \
sed -e 's/^[[:space:]]*//'
echo -ne "\n ${APP}/${CMD}?t=${PASS}${PARA} "
pause
}
pause() {
sleep 1.5
}
invalid() {
echo -ne "\n ${RED}invalid${STD} " && sleep 1
}
preview() {
CMD="PV"
name=$(echo "$0" | awk -F'/' '{print $NF}')
bash $name preview &
OPT="02"; command
echo -ne "\n streaming http://10.5.5.9:8080/live/amba.m3u8 "
read -rsp $'' -n1 key
echo
OPT="00"; command
kill -9 $(ps aux | grep "$name preview" | grep -v root | awk "{print $2}") &> /dev/null
(( $? == 0)) && echo -ne "\n stream closed ";
pause
}
PASS=$(curl -s -m 3 "http://10.5.5.9/bacpac/sd" | sed -e "s/[\o0\o1\o2\o3\o4\o5\o6\o7\o10]//g")
if [[ -z ${PASS} ]]; then
echo "GoPro not connected!"
exit 1
fi
if [[ $# == 0 ]]; then
trap '' SIGINT SIGQUIT SIGTSTP
main
else # PREVIEW
while true; do
# GoPro 3 (keep alive)
curl -s -m 1 "http://10.5.5.9/camera/se?t=${PASS}" &>/dev/null
sleep 2.5
done
fi