Use a GoPro as a remote webcam using Python
I have a GoPro Hero 7 White and I recently discovered I can use it as are remote webcam using a Python package called GoPro API for Python, available at https://github.com/konradit/gopro-py-api.
First install the package using pip3 install goprocam
then enable the WiFi connection on the GoPro.
This makes the GoPro start a WiFi network. Connect to that network from the computer.
Now you’re ready to write your Python program to do whatever you want with the webcam.
Import GoProCamera
and constants
from goprocam
:
from goprocam import GoProCamera, constants
Then call the GoProCamera.GoPro()
method to get a camera object:
gopro = GoProCamera.GoPro(constants.gpcontrol)
Get an overview of the camera status using
gopro.overview()
In my case I got this printed out:
camera overview
current mode: Photo
current submode: Burst
current video resolution: out of scope
current video framerate: 240
pictures taken: 0
videos taken: 0
videos left: 02:10:44
pictures left: 11257
battery left: Halfway
space left in sd card: 58.04GB
camera SSID: HERO7 White
Is Recording: Not recording - standby
Clients connected: 2
camera model: HERO7 White
firmware version: H18.02.02.10.00
serial number: C3343323864041
Now you can use a variety of methods that make the GoPro take actions.
You can take a photo immediately:
gopro.take_photo()
You can take a photo after 2 seconds:
gopro.take_photo(2)
You can shoot a 10-seconds video:
gopro.shoot_video(10)
Or just start recording, with no preset end time, using
gopro.shoot_video()
You can download the last picture or video taken using
gopro.downloadLastMedia()
You can also set a name for the file:
gopro.downloadLastMedia("pic.JPG")
Tip: I ran into a bug that prevented me to download the picture when I called
downloadLastMedia()
. I was getting errors that said “Not supported while recording or processing media”. I had to callgopro.getStatusRaw()
before callingdownloadLastMedia()
to fix it.
There are many useful methods like
KeepAlive()
to prevent the GoPro to turn offsetZoom()
to set the zoomdownloadAll()
to download all media from the cameradelete("last")
to delete the last media takendelete("all")
to delete all mediapower_off()
power off the camerapower_on()
power on the camerastream()
to start streaming (haven’t figured it out yet)
You can find many examples here and more documentation here.
The camera is available on IP 10.5.5.9
, with the MAC address AA:BB:CC:DD:EE:FF
.
I wrote 17 books to help you become a better developer, download them all at $0 cost by joining my newsletter
- C Handbook
- Command Line Handbook
- CSS Handbook
- Express Handbook
- Git Cheat Sheet
- Go Handbook
- HTML Handbook
- JS Handbook
- Laravel Handbook
- Next.js Handbook
- Node.js Handbook
- PHP Handbook
- Python Handbook
- React Handbook
- SQL Handbook
- Svelte Handbook
- Swift Handbook
JOIN MY CODING BOOTCAMP, an amazing cohort course that will be a huge step up in your coding career - covering React, Next.js - next edition February 2025