Control GoPro cameras via USB in Python.
# With Poetry
poetry install
# Or with pip
pip install -e .from gopro_usb import GoProUSB
# Initialize with your GoPro serial number
gopro = GoProUSB("C1234567890")
# Power on the camera
gopro.power_on()
# Configure settings
gopro.mode_video()
gopro.set_resolution_5_3k()
gopro.set_fps_240()
gopro.set_lens_linear()
# Record
gopro.record_start()
time.sleep(10) # Record for 10 seconds
gopro.record_stop()
# Power off
gopro.power_off()See example_usage.py for a complete demonstration including:
- Power on / Power off
- Configuration (5.3K resolution, 240 FPS, Linear Lens)
- Start/stop recording
- Real-time status monitoring
# Run the example
poetry run python example_usage.py
# Or activate the virtual environment
poetry shell
python example_usage.pypower_on()- Power on the camerapower_off()- Power off the camerarecord_start()- Start recordingrecord_stop()- Stop recording
set_resolution_5_3k()- 5.3K resolutionset_resolution_5k()- 5K resolutionset_resolution_4k()- 4K resolutionset_resolution_2_7k()- 2.7K resolutionset_resolution_1080()- 1080p resolution
set_fps_240()- 240 FPSset_fps_200()- 200 FPSset_fps_120()- 120 FPSset_fps_60()- 60 FPSset_fps_30()- 30 FPSset_fps_24()- 24 FPS
set_lens_linear()- Linear (recommended for less distortion)set_lens_wide()- Wideset_lens_narrow()- Narrowset_lens_superview()- SuperViewset_lens_max_superview()- Max SuperViewset_lens_linear_horizon()- Linear + Horizon Lock
get_state()- Get complete stateget_status_realtime(interval, duration)- Real-time monitoringis_busy()- Check if camera is busyis_encoding()- Check if encoding is in progress
mode_video()- Video modemode_photo()- Photo modemode_timelapse()- Timelapse mode
get_media_list()- List files on SD carddownload_last_media(filename)- Download last file
The class uses the GoPro's IP address based on its serial number:
- IP Format:
172.2{digit3}.1{digit2-3}.51 - Example: SN "C1234567890" → IP
172.29.190.51
Make sure that:
- The GoPro is connected via USB
- USB control is enabled on the camera
- Your computer can communicate with the GoPro's IP
Based on goproUSB by Lukasz J. Nowak.
Modifications and additions:
- Complete refactoring into Python class
- OpenCV support for local preview
- Configuration for GoPro Hero 12 Black
- Real-time monitoring support
- Media download support
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
As a derivative of goproUSB, this project complies with the GPL v3.0 terms which require that any modification or derivative work must also be distributed under GPL v3.0.