gopro-py-api
gopro-py-api copied to clipboard
GoPro Hero 8 USB live streaming url with opencv
Hi, I wanted to broadcast from GoPro Hero 8 firmware 2.50 using USB and display live with opencv (windows 10)
I used ifaddr interface to get the IP address (work fine)
for adapter in ifaddr.get_adapters():
if "GoPro" in adapter.nice_name:
for ip in adapter.ips:
if ip.is_IPv4:
addr = ip.ip.split(".")
addr[len(addr) - 1] = "51"
addr = ".".join(addr)
then I used the IP address to wake up the gopro (goprocam 4.1.0)
gopro = GoProCamera.GoPro(ip_address=addr, camera=constants.gpcontrol)
I want to get the live streaming by using livestream("start") function, but I lost here, I get an error when I pass the address in opencv
cam= cv2.VideoCapture(addr)
_, frame = cam.read()
cv2.imshow('Image', frame)
error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'
I even tried with vlc with this url: http://IP_address/gp/gpControl/execute?p1=gpStream&c1=start but nothing shows up
You have to use a properly constructed UDP URI.
udp://%s:8554 % addr
u mean by using gopro.stream("udp adress") function?
Nope. For stream function you have to provide your own addy.
Finally I figure it out After waking up the camera, I must call the startWebcam() function, then use an udp address, it work fine with opencv
gopro = GoProCamera.GoPro(ip_address=addr, camera=constants.gpcontrol)
gopro.startWebcam()
udp_addr = "udp://@{}:8554".format(addr)
Sorry @KonradIT another question, After calling the stopWebcam() function, the camera mantain on the ready mode is there in a function to put in normal mode or something ?
What do you mean normal mode? You could try putting it in video/photo mode.
For you question I mean the mode that display usb connected on the camera screen putting it in video mode, l will try that
hi again @KonradIT I wanted to connect two cameras GoPro using usb and stream each one independently unfortunately, I didn't get wat I expect, just look in the link below : https://streamable.com/pp2ian I get one stream for the both cameras
Yep, that happens when a system receives 2 UDP streams on the same port (albeit different IP addresses)
Can I use another port than 8554 ? or it's impossible
You could use an intermediary device, eg: raspberry pi to ingest via port 8554, and then output via a different port.
I need to connect two camera to raspberry Pi. When using alone it's working fine how can connect both. How can the swtich the on stream to redirect.
How can I switch the port? For one camera
I am using this method. this good working when I use one Gopro Camera. https://github.com/KonradIT/goprowifihack/blob/master/HERO9/GoPro-Connect.md