├── README.md ├── hero3.py ├── LICENSE.txt └── hero4.py /README.md: -------------------------------------------------------------------------------- 1 | # Reverse Engineered, FFmpeg-based GoPro HERO4/4+ Streaming Viewer 2 | 3 | A utility for viewing the low-latency live video stream from a GoPro HERO4 or HERO4+ over the built-in WiFi link on a Linux or OSX based computer. 4 | 5 | ## Requirements 6 | * GoPro Hero4 or newer 7 | * ffplay + ffmpeg libraries 8 | * Python 2.7.x or 3.x 9 | * requests Python module 10 | 11 | 12 | ## Usage 13 | * Set GoPro Wifi settings to "GoPro App" 14 | * Connect to GoPro's WiFi network 15 | * Run: player.py 16 | -------------------------------------------------------------------------------- /hero3.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import requests 3 | import getpass 4 | import os,time,sys 5 | from time import sleep 6 | import threading 7 | 8 | def video(): 9 | os.system("ffplay -fflags nobuffer -f:v hls http://10.5.5.9:8080/live/amba.m3u8") 10 | 11 | def keepalive(pwd): 12 | 13 | while True: 14 | print("refresh...") 15 | requests.get("http://10.5.5.9/camera/PV?t=%s&p=%%02" % pwd) 16 | time.sleep(1.0) 17 | 18 | exitFlag = 0 19 | 20 | class kathread (threading.Thread): 21 | def __init__(self, threadID, name, pwd): 22 | threading.Thread.__init__(self) 23 | self.threadID = threadID 24 | self.name = name 25 | def run(self): 26 | print("Starting " + self.name) 27 | keepalive(pwd) 28 | print("Exiting " + self.name) 29 | 30 | 31 | pwd = getpass.getpass() 32 | thread1 = kathread(1, "Thread-1", pwd) 33 | 34 | # Start new Threads 35 | thread1.start() 36 | time.sleep(3.0); 37 | video() 38 | print("Exiting Main Thread") 39 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Nash Kaminski 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /hero4.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import requests 3 | import os,time,sys 4 | from time import sleep 5 | import threading 6 | import socket 7 | 8 | def video(): 9 | r=requests.get("http://10.5.5.9/gp/gpControl/execute?p1=gpStream&c1=restart") 10 | print(r.text) 11 | time.sleep(3.0); 12 | os.system("ffplay -fflags nobuffer -f:v mpegts -probesize 8192 udp://:8554") 13 | 14 | def keepalive(): 15 | 16 | def get_command_msg(id): 17 | return "_GPHD_:%u:%u:%d:%1lf\n" % (0, 0, 2, 0) 18 | 19 | UDP_IP = "10.5.5.9" 20 | UDP_PORT = 8554 21 | KEEP_ALIVE_PERIOD = 250 22 | KEEP_ALIVE_CMD = 2 23 | MESSAGE = get_command_msg(KEEP_ALIVE_CMD) 24 | 25 | print("UDP target IP:", UDP_IP) 26 | print("UDP target port:", UDP_PORT) 27 | print("message:", MESSAGE) 28 | 29 | if sys.version_info.major >= 3: 30 | MESSAGE = bytes(MESSAGE, "utf-8") 31 | 32 | while True: 33 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 34 | sock.sendto(MESSAGE, (UDP_IP, UDP_PORT)) 35 | sleep(KEEP_ALIVE_PERIOD/1000) 36 | 37 | exitFlag = 0 38 | 39 | class kathread (threading.Thread): 40 | def __init__(self, threadID, name): 41 | threading.Thread.__init__(self) 42 | self.threadID = threadID 43 | self.name = name 44 | def run(self): 45 | print("Starting " + self.name) 46 | keepalive() 47 | print("Exiting " + self.name) 48 | 49 | thread1 = kathread(1, "Thread-1") 50 | 51 | # Start new Threads 52 | thread1.start() 53 | video() 54 | print("Exiting Main Thread") 55 | --------------------------------------------------------------------------------