goproh4
Node.js module to control a GoPro Hero 4
var GoPro = ; var cam = ; // Set camera modecam // Set camera resolution // Set camera framerate // Begin recording // Wait 10s // Stop recording;
Installation
$ npm install goproh4
Features
- Get camera status
- Get/Set camera settings
- Take a picture, video, timelapse...
- View live video feed from within your browser
- Turn ON/OFF the camera
- List/retrieve information of the files on the camera
Note: Hero4 support only
How to use it
Note: All functions except GoPro.Camera.powerOn()
are using Promise
Basics
Create camera object
var GoPro = ; var cam = ;
Options can be given:
var cam = ip: '10.5.5.9' /* Gopro ip, should be 10.5.5.9 except in remote mode */ broadcastip: '10.5.5.255' /* Broadcast ip of the gopro network, use to wake up the gopro (WOL protocol), should be 10.5.5.255 */ mac: 'xx:xx:xx:xx:xx:xx' /* Mac address, used to wake up the gopro, should be set if the camera is off before launching the script, available at cam._mac. Will be retrieved if not present. */;
Record a video
// Set camera modecam // Set camera resolution // Set camera framerate // Begin recording // Wait 10s // Stop recording;
Livestreaming from Web browser
Requirements:
- ffmpeg
- Go to livestream directory
npm install
node livestream.js
(make sure you are connected to your GoPro's wifi before launching this command)- Open http://127.0.0.1:8082/index
Settings
All the camera settings can be found in lib/constant.js. Accessible through the object
GoProSettings
Settings name are in capital letters:
GoProSettingsVIDEO_RESOLUTION
Settings value are in camelcase:
GoProSettingsVideoResolutionR1080S
`GoPro.Camera.set(setting_id, setting_value)` ```js cam.set(GoPro.Settings.VIDEO_RESOLUTION, GoPro.Settings.VideoResolution.R1080S).then(function () { console.log('[video resolution set to 1080p Superview]'); }); ```
`GoPro.Camera.set(setting_id)` ```js cam.set(GoPro.Settings.VIDEO_RESOLUTION).then(function (setting_value) { console.log('[video resolution is] = ', setting_value); }); ```
Mode
Change gopro mode/submode using GoPro.Camera.mode(mode, submode)
cam;
Note: there is an hidden mode called Broadcast
, for now I haven't been able to correctly use it, I suppose it's a coming feature.
Status
Get gopro status using GoPro.Camera.status(status_id)
camstatusGoProStatusInternalBatteryLevel;
Documentation
Methods | Description |
---|---|
Camera.ready() |
Resolved when the camera mac address has been retrieved. see example |
Camera.status([id]) |
Get all status from camera or status equals to id |
Camera.mode(mode [,submode]) |
Change GoPro's mode and optionally submode |
Camera.start() |
Start recording video/picture/timelapse/... |
Camera.stop() |
Stop recording video/timelapse |
Camera.startStream() |
Send command to the Camera to start streaming & send a keepalive command every 2,5s |
Camera.restartStream() |
Send command to the Camera to restart streaming & send a keepalive command every 2,5s |
Camera.stopStream() |
Send command to the Camera to stop streaming & stop sending the keepalive command |
Camera.set(setting_id [,setting_value]) |
Set Camera setting to given value or optional get its value by not providing one |
Camera.powerOn() |
Turn on the Camera using Wake-on-Lan, Camera's MAC address needs to be known |
Camera.powerOff() |
Turn off the Camera |
Camera.listMedia() |
Get list of all media in the Camera's storage |
Camera.getMediaStream(directory, filename) |
Starts downloading media, sends back a stream |
Camera.getMedia(directory, filename, path) |
Download media to file |
Camera.deleteAll() |
Delete all media from Camera's storage |
Camera.deleteLast() |
Delete last media from Camera's storage |
Camera.videoInfo(video_path) |
Get information about a video |
Examples
Go to examples