Stream to PC from GoPro Hero4 Black
/One of our recent design improvements is the addition of a GoPro Hero4 Black. Admittedly, I bought it without much research because the thing looks friggin awesome. I mean, look at that beaut...
Pros:
- Small, fits in the palm of your hand
- 4k @~30fps, and more fps for less resolution
- Modes out the wazoo, including low-light
- Waterproof to ~140ft
Cons:
- < 1hr battery life
- Lack of public API
- Pricey
- No wired streaming
- Noticeable latency
When it comes to streaming, GoPro provides only one option-- mobile devices. They've made it very clear that the primary use case, in their eyes, remains on-device recording and playback. However, they left open a REST interface for all commands and settings, almost undoubtedly intentionally. Find all of those commands here.
Finally, the steps I followed to stream the Hero4 to my Mac. The specific commands will vary between OSes, but the general instructions are the same.
- Install ffmpeg & ffplay. On OS X, that's brew install ffmpeg --with-ffplay
- Install GoPro app on your mobile device, use it to setup wireless, and stream video to that device. That last part is important, as I believe it initializes something important.
- Connect to your GoPro's wireless network.
- Back out of all menus on the GoPro device. I've noticed the device may not be able to stream when it's in a menu.
- Open your computer's firewall to port 8554 for UDP traffic.
- In a terminal, ffplay udp://:8554
- In a web browser, go to http://10.5.5.9/gp/gpControl/execute?p1=gpStream&c1=restart. You should see the response {"stream" : "0"}.
When you flip over to the ffplay window, you should see a streaming video from your GoPro with very high latency (~6s). To remedy this to some extent, stop ffplay, and repeat steps four and five, but replace step four with ffplay -fflags nobuffer -f:v mpegts -probesize 8192 udp://:8554. This should bring the latency down to less than 2s.
Note that when the Hero4 Black first came out, GoPro release it with a different firmware, whose commands were different. If the above steps don't work for you, check your firmware version against the latest.
Bonus: Underwater!
Our use case for this camera was going to travel one of two paths. Either we'd simply attach it to the outside of the sub and press record before letting it loose, or we'd also stream video back to one of the computers for real-time image processing. Since the GoPro Hero4 Black acts as a wireless access point, we thought we could potentially connect to it, through ~1ft of water, from inside the sub. Turns out it works in the bathtub (i.e. not salt water) to just under a foot!
References:
https://www.reddit.com/r/gopro/comments/2md8hm/how_to_livestream_from_a_gopro_hero4/cr1b193
https://www.reddit.com/r/gopro/comments/2md8hm/how_to_livestream_from_a_gopro_hero4/coh94hi