This repository was archived by the owner on Apr 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart_stream_gopro.py
More file actions
53 lines (39 loc) · 1.58 KB
/
start_stream_gopro.py
File metadata and controls
53 lines (39 loc) · 1.58 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/python
import sys
import json
import socket
import requests
from time import sleep
#This script allows you to maintain a connection to the Go Pro over Wifi
#Generally the Go Pro can't sustain a wifi connection for more than 20 mins,
#and while streaming that capacity drops to only 2 mins.
#In order to use the script make sure you are connected to the GoPro's wifi
def get_command_msg(id):
return "_GPHD_:%u:%u:%d:%1lf\n" % (0, 0, 2, 0)
if __name__ == "__main__":
#Go Pro Livestream start link
#http://10.5.5.9/gp/gpExec?p1=gpStreamA9&c1=restart
uri_status='http://10.5.5.9:8080/gp/gpControl/execute?p1=gpStream&c1=restart'
req=requests.get(uri_status)
#Try to send the signal to start the stream
if req.status_code != 200:
print"Cannot connect to Go Pro" + "\n" +"Check connection-manager"
sys.exit()
else:
# Keep stream Alive python script from:
#https://gist.github.com/3v1n0/38bcd4f7f0cb3c279bad#file-hero4-udp-keep-alive-send-py
#as on 20 July 2017 22:48
UDP_IP = "10.5.5.9"
UDP_PORT = 8554 #port where the Go Pro Hero4 video streams
KEEP_ALIVE_PERIOD = 2500
KEEP_ALIVE_CMD = 2
MESSAGE = get_command_msg(KEEP_ALIVE_CMD)
print("UDP target IP:", UDP_IP)
print("UDP target port:", UDP_PORT)
print("message:", MESSAGE)
if sys.version_info.major >= 3:
MESSAGE = bytes(MESSAGE, "utf-8")
while True:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))
sleep(KEEP_ALIVE_PERIOD/1000)