Sunday, February 17, 2013

capturing a live stream from the GoPro Hero 2 to a PC

I wanted to make a multi-camera video using Linux of my new drum set, the Roland TD-30K.  Also, I didn't want to fuss with storage media; in other words, the dance of:
- record video to a device
- pull out the storage media  from the device (Compact Flash/tape/SDHC card, what have you)
- connect the storage media to the PC
- copy the files to the PC

What a pain that sh1t is. So the second goal was to record all three streams direct to the PC.  Now, I have an older JVC HD10U 720P video cam.  I knew I could grab the stream over firewire.  Also, I have a Logitech C910 webcam.  With the Logitech, I knew I could grab its video as well.  I had two other cameras as potential for this experiment:
- my lovely Canon 5D or
- the GoPro Hero 2

The Canon wouldn't work, as there is no streaming option by default.  I'd need some hardware HD streaming solution to do that:

However, with the release of the GoPro iPhone app, the GoPro guys have coded a way to stream; it was just a question of whether or not I could hook into it.  After doing some digging on this great thread over at the GoPro User Forums ( and with a healthy dose of experimentation, I was able to do it.  More for my notes than anything else, here's how you can stream from your GoPro Hero 2 to your PC.

- GoPro Hero 2
- GoPro WIFI BacPac
- PC with FFmpeg installed (my test results were conducted on Fedora 17 Linux)
- Validate that your Hero 2 and WIFI BacPac are up-to-date with the latest firmware versions. As of this writing on 2/17/13, those versions are:
Hero 2: 8.12.222
BacPac: 3.4.1

If the software on these devices is not up-to-date, the below instructions won't work for you.  Also, I don't know if these commands work on a Hero 3, as I don't have one.  Though someone apparently got it to work here:

1) Update the firmware on your BacPac and GoPro Hero 2 if they are not updated!
2) turn on the BacPac
3) turn on the GoPro Hero 2
4) When turned on, press the menu button on the WIFI BacPac.  The screen of the Hero 2 will give you the option to connect to a Phone or Tablet.  Select this option.

This is interesting because when you select the option, the BacPac creates it's own wireless access point at the IP  I created an /etc/hosts file entry for the BacPac so that I didn't have to type the IP all the time:

[sodo@computer ~]$ ping gp
PING gopro ( 56(84) bytes of data.
64 bytes from gopro ( icmp_req=1 ttl=64 time=1.81 ms
64 bytes from gopro ( icmp_req=2 ttl=64 time=0.742 ms

If you do a network map of the network, you'll find two devices:
[sodo@computer ~]$ nmap -A
Starting Nmap 6.01 ( ) at 2013-02-17 11:38 EST
Stats: 0:01:11 elapsed; 254 hosts completed (2 up), 2 undergoing Service Scan
Service scan Timing: About 85.71% done; ETC: 11:39 (0:00:11 remaining)

Nmap scan report for gopro (
Host is up (0.0060s latency).
Not shown: 998 closed ports
80/tcp   open  http?
8080/tcp open  http    Cherokee httpd 1.2.101b121204_
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at :
Service Info: OS: Unix

Nmap scan report for
Host is up (0.0011s latency).
Not shown: 995 closed ports
PORT      STATE SERVICE                VERSION
22/tcp    open  ssh                    OpenSSH 5.9 (protocol 2.0)
| ssh-hostkey: 1024 84:a4:7c:c7:42:e5:53:f3:64:a2:89:2c:5e:97:26:60 (DSA)
|_2048 a2:27:68:40:d4:9f:90:72:f2:6c:0b:99:75:67:c3:76 (RSA)
111/tcp   open  rpcbind (rpcbind V2-4) 2-4 (rpc #100000)
| rpcinfo: 
|   program version   port/proto  service
|   100000  2,3,4        111/tcp  rpcbind
|_  100000  2,3,4        111/udp  rpcbind
888/tcp   open  ssl/hbase-master       Apache Hadoop Hbase 2.0
|_sslv2: server still supports SSLv2
|_http-methods: No Allow or Public header in OPTIONS response (status code 404)
|_http-title: 3ware 3DM2 - computer - Summary
| ssl-cert: Subject: commonName=computer/organizationName=3ware Inc./countryName=US
| Not valid before: 2011-10-28 18:44:48
|_Not valid after:  2021-10-26 18:44:48
902/tcp   open  ssl/vmware-auth        VMware Authentication Daemon 1.10 (Uses VNC, SOAP)
16001/tcp open  fmsascon?
Service Info: Host: computer; Device: storage-misc

Note that if you perform the nmap command, you may lose connectivity to the GoPro and will have to restart both the WIFI BacPac and the main body of the GoPro.

5) Connect your PC to the BacPac's wireless access point (WAP) at  The default password is GoProHero.  Important note:

*** In order to send commands to the GoPro via its Cherokee Web Server, you need to connect the computer on which you have a running browser to the wireless access point that the GoPro creates in step 4 ***

6) After you've connected to the BacPac WAP, you'll need to instruct the GoPro to start streaming.  You can do this by sending commands to the webserver that is running on port 80.  Here is the command to start the stream:

You'll need to substitute the password (default or your own custom password) for the GoPro where I've written WIRELESSPASSWORD.  The %02 says.."start streaming".  You can turn off streaming by sending the same command, only using %01 on the end:

Someone compiled a list of commands that you can send to the GoPro using the web interface.  I've listed those commands at the bottom of this post.  Also, an enterprising gentleman has created a Windows app to send the various commands to your GoPro while it is in wireless tablet mode:

7) If you've started streaming, validate that the little files that represent the streaming are posted to the Cherokee webserver by visiting this URL:

You should see the files listed in the browseable directory.  This means that the stream is running and that you can capture it:

8) Once the stream is running, use FFplay (a media player bundled with FFmpeg) to validate the stream works:
[sodo@computer ~]$ ffplay -i
ffplay version 0.10.6 Copyright (c) 2003-2012 the FFmpeg developers
  built on Dec  1 2012 12:21:08 with gcc 4.7.2 20120921 (Red Hat 4.7.2-2)
[applehttp @ 0x7fa0600008c0] Estimating duration from bitrate, this may be inaccurate
Input #0, applehttp, from '':
  Duration: N/A, start: 144.977167, bitrate: N/A
    Stream #0:0: Video: h264 (Main) (HDMV / 0x564D4448), yuv420p, 432x240 [SAR 1:1 DAR 9:5], 29.97 tbr, 90k tbn, 59.94 tbc
 154.92 A-V:  0.000 fd=   0 aq=    0KB vq=   21KB sq=    0B f=0/0   0/0 

I've bolded some interesting things about the stream:
* the format is Apple's HTTP Live Streaming (HLS) format (FFmpeg calls this "applehttp"
* the stream is H264 compression
* color model is yuv420p
* size of the stream is 432x240
* framerate is 29.97

Here's a snap of the output

Holy works!  The best thing about this is now you can capture the output to a file like so:
ffmpeg -y -i -c:v copy -an test.mp4

The above command captures the stream and copies it (-c:v copy) in the same format it was sent.  For my purposes, this was best as I did not have to re-encode the stream.  I simply "copied" the stream to the hard drive of my Linux box.  This saved CPU processor for the other two streams I captured.

I put this stream together along with the other two streams in a sample video of my new drum kit.  Only bummer is that the GoPro stream of my kick pedals is that it is so low rez:

If anyone has a clue as to how to edit the firmware to increase the resolution of the stream that gets saved to webroot of the Cherokee web server, please let me know.  I'd love to be able to suck up a video stream that is higher rez than 420P.

So that's it.  I'd really like to be able to tweak the firmware of the GoPro Hero 2 in order to increase the resolution of the stream to capture, but it looks like that hasn't been fully accomplished yet unlike Magic Lantern for the Canon 5D.  Though folks are trying!



Apple's HLS Streaming Format

Commands you can send to the GoPro while Phone/Tablet Streaming is active
Update 2013/04/19
Added the correct syntax for password original cut-and-paste included HTML characters that broke the display of the commands in Blogger
*** end update ***
The general query structure is: 

Where: can be bacpac or camera.

Queriable Information
Turn on camera : http:///bacpac/PW?t=[password]&p=%01
Turn off camera : http:///bacpac/PW?t=[password]&p=
Change mode : http:///bacpac/PW?t=[password]&p=%02

Start capture : http:///bacpac/SH?t=[password]&p=%01
Stop capture : http:///bacpac/SH?t=[password]&p=

On : http:///camera/PV?t=[password]&p=%02
Off : http:///camera/PV?t=[password]&p=

Camera : http:///camera/CM?t=[password]&p=
Photo : http:///camera/CM?t=[password]&p=%01
Burst : http:///camera/CM?t=[password]&p=%02
Timelapse : http:///camera/CM?t=[password]&p=%03
Timelapse : http:///camera/CM?t=[password]&p=%04

Head up : http:///camera/UP?t=[password]&p=
Head down : http:///camera/UP?t=[password]&p=%01

Set Resolution of Video Recorded to the Device
WVGA-60 : http:///camera/VR?t=[password]&p=
WVGA-120 : http:///camera/VR?t=[password]&p=%01
720-30 : http:///camera/VR?t=[password]&p=%02
720-60 : http:///camera/VR?t=[password]&p=%03
960-30 : http:///camera/VR?t=[password]&p=%04
960-60 : http:///camera/VR?t=[password]&p=%05
1080-30 : http:///camera/VR?t=[password]&p=%06

wide : http:///camera/FV?t=[password]&p=
medium : http:///camera/FV?t=[password]&p=%01
narrow : http:///camera/FV?t=[password]&p=%02

Photo Resolution
11mp wide : http:///camera/PR?t=[password]&p=
8mp medium : http:///camera/PR?t=[password]&p=%01
5mp wide : http:///camera/PR?t=[password]&p=%02
5mp medium : http:///camera/PR?t=[password]&p=%03

Photo Resolution in Black Edition
12mp w : http:///camera/PR?t=[password]&p=%05
07mp w : http:///camera/PR?t=[password]&p=%04
07mp m : http:///camera/PR?t=[password]&p=%06
05mp m : http:///camera/PR?t=[password]&p=%03

Delete (may only work on Black Edition..not confirmed)

All (Format)

0,5sec : http:///camera/TI?t=[password]&p=
1sec : http:///camera/TI?t=[password]&p=%01
2sec : http:///camera/TI?t=[password]&p=%02
5sec : http:///camera/TI?t=[password]&p=%03
10sec : http:///camera/TI?t=[password]&p=%04
30sec : http:///camera/TI?t=[password]&p=%05
60sec : http:///camera/TI?t=[password]&p=%06

On : http:///camera/LL?t=[password]&p=%01
Off : http:///camera/LL?t=[password]&p=

Bip Volume
0% : http:///camera/BS?t=[password]&p=
70% : http:///camera/BS?t=[password]&p=%01
100% : http:///camera/BS?t=[password]&p=%02


DD said...

Thanks this is awesome! Exactly what I was looking for! I'm using a hero3, and although I can capture the stream, I don't seem to be able to send any signals to the device. I'm wondering if the web API has changed. How did you discover these commands? Is there a way to sniff the table application messages to deconstruct these?

Cacasodo said...

I only have the Hero2, unfortunately, so I can't help you test. Most of the information in my post was culled from this link:

If the comands sent via the URL don't work, yes, you're sounds like something changed between Hero2 and Hero3. I believe the parameters sent via the URL were more or less guessed at by the guy who compiled the list. If you read through the entire thread, you might be able to glean something about the method by which the guy found them in the first place. I think it was trial and error.

If I get my hands on a Hero3, I'll test it out myself.

Unknown said...
This comment has been removed by a blog administrator.
Unknown said...

Delete doesn't work but this does work on a Hero 3+ Black:


Cacasodo said...

Thanks Onno.

Unknown said...
This comment has been removed by a blog administrator.
Unknown said...

Thx for the article, it was a good starting point for me.
I noticed that in the original GoPro app the delay of the video is around 1sec which is very nice. If I playback with AVFoundation (AVPlayer etc.) the delay is around 3sec which is quiet a lot. I haven't tried ffmpeg. How is the delay with it? Any suggestions how to reduce the delay?

Cacasodo said...

As I recall, I think the delay was about 1/2 a second on my GoPro Hero 2. Since I was going to sync my saved video to a second video stream later, I really didn't care about the delay. I just needed a reference point in the video by which to sync the multiple streams, so I just clapped my hands as if I had a true movie clapboard.

Not sure how to reduce your delay time. I assume you'd need to make sure you're close to your WIFI access point and that the machine your capturing the stream from is sufficiently fast. That wasn't a requirement for me as I merged streams later on.

good luck,

Unknown said...
This comment has been removed by a blog administrator.
Cacasodo said...

Great post..will have to try out those other methods of live streaming.

Unknown said...

I tried everything and i read more than 100 articles about live streaming and i finally found this right one, how to live stream with gopro -

Feel free to drop me a line or ask me a question.