KonradIT / goprowifihack

Unofficial GoPro WiFi API Documentation - HTTP GET requests for commands, status, livestreaming and media query.
Apache License 2.0
2.13k stars 335 forks source link

Hero 4 Session LiveStream in v02.00 #47

Closed ivanmkc closed 8 years ago

ivanmkc commented 8 years ago

Problem:

Livestream GET request has no effect.

Side-note: I would like to help investigate this. What's the best way to set up the packet sniffing on Android to do that? Thanks!

Details:

I sent the GET request: http://10.5.5.9/gp/gpControl/execute?p1=gpStream&a1=proto_v2&c1=restart

I get the response: {status: "0"}

Live stream mode does not start. I can confirm this by no change on the Hero 4 Session Display, as well as no UDP packet stream for video.

KonradIT commented 8 years ago

Hi @ivanmkc, use the GoPro App to make sure your camera is up to date. I recently played around with a HERO4 Silver and used the URL you mentioned to get a live feed using FFplay.

ivanmkc commented 8 years ago

Thanks for the quick response @KonradIT. It is brand new and up-to-date.

From the official site (https://gopro.com/update/hero4_session), the Hero 4 Session runs the HERO4 Session v02.00 firmware (March 31, 2016) and the Hero 4 Black\Silver run firmware v03.00.00 (July 30, 2015). Given the 8 month difference in release, I'm not surprised that there are discrepancies between them.

I'd love your help resolving this, but I don't mind helping either if you tell me how I can best contribute.

Thanks, Ivan

ivanmkc commented 8 years ago

For reference here is the output from: http://10.5.5.9/gp/gpControl

The GET request looks to be as your guide says them to be, but the GoPro4 Session just doesn't react to the command. hero4SessionReference.txt

KonradIT commented 8 years ago

@ivanmkc crap I read it as HERO4 Silver, I am aware of this problem as I have a HERO4 Session myself and cannot get to stream. I tried using Charles Proxy but didn't get anything relevant. I have the Session with me now, will see what I can do

ivanmkc commented 8 years ago

@KonradIT Ya I picked the session as its form factor makes it great for mounting on a drone. I think I read that you had interest in drones as well ;)

How do you set up Charles proxy to view the Android traffic? I used Wireshark on my Mac (on promiscuous mode) and couldn't see it. Would love to help.

KonradIT commented 8 years ago

If your Android phone is rooted, try Termux or Terminal Emulator with tcpdump or mitmdump, that should help. Or decompile the GoPro smarty apk

KonradIT commented 8 years ago

OK I know what's happening here (I guess). My phone being pity does not let me run tcpdump/mitmdump because of some PIE setting. I used "Packet Capture" app from the Play Store and got some interesting requests. The app is wonderful: no root needed, material design...

Screenshots here:

http://i.imgur.com/VviiGhB.png

http://i.imgur.com/bmLKIRX.png

That is 3 methods of turning the preview ON

KonradIT commented 8 years ago

Forgot to mention /gp/gpControl/camera/PV/2 gives 500 Internal Error. /camera/PV/2 is used in HERO2 and HERO3 cameras but not in HERO4, I think they just messed up (being GoPro, it does not surprise me at all)

ivanmkc commented 8 years ago

I used the app like you suggested. It shows me what you screenshotted.

So is the answer to send a preview ON request after sending the stream request?

KonradIT commented 8 years ago

I will need to reproduce everything in the right order later

ivanmkc commented 8 years ago

Ok, let me know when you do and I'll test it out. Thanks!

On Wed, Jul 20, 2016 at 2:50 PM, Konrad Iturbe notifications@github.com wrote:

I will need to reproduce everything in the right order later

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/KonradIT/goprowifihack/issues/47#issuecomment-234045001, or mute the thread https://github.com/notifications/unsubscribe-auth/ABgzgZow9CVm0eO0_hOkoeteoMrg63Geks5qXm4DgaJpZM4JQ_U6 .

KonradIT commented 8 years ago

@ivanmkc have you gotten anything? just got home so I'll see if I can get a working stream

KonradIT commented 8 years ago

I'd take a bet and say that maybe they keep preview alive by using /gp/gpControl/status every second?

KonradIT commented 8 years ago

GoPro app also sends outdated or bad requests, such as the pairing success and the /camera/PV/2 from HERO3... why?

ivanmkc commented 8 years ago

Ya, I wonder if the outdated requests are actually being used for some side-effect that keeps the connection alive. I'm bogged down with work this week but I'll try this out later on in the week.

Ivan

On Sat, Jul 23, 2016 at 7:44 AM, Konrad Iturbe notifications@github.com wrote:

GoPro app also sends outdated or bad requests, such as the pairing success and the /camera/PV/2 from HERO3... why?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/KonradIT/goprowifihack/issues/47#issuecomment-234714022, or mute the thread https://github.com/notifications/unsubscribe-auth/ABgzgUkFvSexRO2kdLWhNkRYZyxbvdh2ks5qYf6VgaJpZM4JQ_U6 .

KonradIT commented 8 years ago

Got the preview working in FFplay after using the GoPro App on mobile. They still use udp 8554, although I didn't check any variable status in /gp/gpControl/status

https://i.sli.mg/FEq7IG.png

All its missing is a preview ON url

ivanmkc commented 8 years ago

Ah I should have mentioned that was what I was doing to get it working in the meantime. Seems like the stream is working fine as you say.

On Mon, Jul 25, 2016 at 5:51 AM, Konrad Iturbe notifications@github.com wrote:

Got the preview working in FFplay after using the GoPro App on mobile. They still use udp 8554, although I didn't check any variable status in /gp/gpControl/status

https://i.sli.mg/FEq7IG.png

All its missing is a preview ON url

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/KonradIT/goprowifihack/issues/47#issuecomment-234910225, or mute the thread https://github.com/notifications/unsubscribe-auth/ABgzgfESMCNrVLbOTKfrCaC_nvdYrNuPks5qZIcugaJpZM4JQ_U6 .

chengsam commented 8 years ago

Hi guys, I am trying to get my Session to stream to an iOS app. I am able to stream for now but encounters some difficulties for it to stream easily. I am not able to stream immediately after turning the wifi of GoPro on but after I tried visiting gp/gpControl/status for several times it can start to stream. I don't know if this is the magic method to allow it to start streaming. Also, the python script I used sends the "GPHD:0:0:2:0.00000" command to keep it alive. Can I do it also on iOS? Thank you.

KonradIT commented 8 years ago

gp/gpControl/status for several times

I had my doubts regarding this but since you got it working I'll update the repo accordingly.

The python sends a magic packet with that command, same as GoPro App, you need to find a library for ObjC that does that, such as this one (Not tested with Hero4 Session!)

I'll confirm later on that the stream works with Hero4 Session on FFplay

chengsam commented 8 years ago

Your doc mentioned that the magic packet is as:

send a magic packet (WoL) with these parameters: MAC ADDRESS OF THE CAMERA, 10.5.5.9 as IP ADDRESS, Subnet Mask 255.255.255.0, Port 9.

But the python script sent "GPHD:0:0:2:0.00000", are they the same? Is this command only used for keeping the streaming alive and I need to send a magic packet first for it to start streaming?

KonradIT commented 8 years ago

@chengsam No they are not the same, I think that keeps the stream alive where as the magic packet turns on the camera

chengsam commented 8 years ago

OK, I can stream the preview to my app now. However, the delay is ~5s. Just figuring out how to reduce the latency.

KonradIT commented 8 years ago

@chengsam didn't have time yesterday I was travelling, did you send /gp/gpControl/status GET request to start the stream? Are you on 2.00?

chengsam commented 8 years ago

Yes, I sent /gp/gpControl/status several times until the status 31 of the camera and it's not 0 to start the stream. But I'm not sure if it works all the time. And my version is 2.00.

KonradIT commented 8 years ago

Can confirm it works with pinging /gp/gpControl/status 5 times. I only neeeded to HTTP GET the URL 5 times at the start and then run the stream on FFplay. I used this script and it worked. I'll push a PR to add HERO4 Session support and update the docs on this repo accordingly.

Proof: http://imgur.com/a/PHtoi

Closing thread.

chengsam commented 8 years ago

I found that sometimes it requires me to ping more than 5 times to make status 31 > 0. So in my implementation, i check for the count of status 31 and start the stream when it's not 0.

KonradIT commented 8 years ago

@chengsam I'll write it then, thanks!