npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

goproh4

v0.4.2

Published

API for controlling GoPro Hero 4 cameras

Downloads

16

Readme

goproh4

Node.js module to control a GoPro Hero 4

var GoPro = require('goproh4');

var cam = new GoPro.Camera();

// Set camera mode
cam.mode(GoPro.Settings.Modes.Video, GoPro.Settings.Submodes.Video.Video)

// Set camera resolution
.then(function () {
    return cam.set(GoPro.Settings.VIDEO_RESOLUTION, GoPro.Settings.VideoResolution.R1080S)
})

// Set camera framerate
.then(function () {
    return cam.set(GoPro.Settings.VIDEO_FPS, GoPro.Settings.VideoFPS.F60)
})

// Begin recording
.then(function () {
    console.log('[video]', 'started')
    return cam.start()
})

// Wait 10s
.delay(10000)

// Stop recording
.then(function () {
    console.log('[video]', 'stopped')
    return cam.stop()
});

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 = require('goproh4');

var cam = new GoPro.Camera();

Options can be given:

var cam = new GoPro.Camera({
    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 mode
cam.mode(GoPro.Settings.Modes.Video, GoPro.Settings.Submodes.Video.Video)

// Set camera resolution
.then(function () {
    return cam.set(GoPro.Settings.VIDEO_RESOLUTION, GoPro.Settings.VideoResolution.R1080S)
})

// Set camera framerate
.then(function () {
    return cam.set(GoPro.Settings.VIDEO_FPS, GoPro.Settings.VideoFPS.F60)
})

// Begin recording
.then(function () {
    console.log('[video]', 'started')
    return cam.start()
})

// Wait 10s
.delay(10000)

// Stop recording
.then(function () {
    console.log('[video]', 'stopped')
    return cam.stop()
});

Livestreaming from Web browser

Requirements:

  • ffmpeg
  1. Go to livestream directory
  2. npm install
  3. node livestream.js (make sure you are connected to your GoPro's wifi before launching this command)
  4. Open http://127.0.0.1:8082/index

Settings

All the camera settings can be found in lib/constant.js. Accessible through the object

GoPro.Settings

Settings name are in capital letters:

GoPro.Settings.VIDEO_RESOLUTION

Settings value are in camelcase:

GoPro.Settings.VideoResolution.R1080S

Mode

Change gopro mode/submode using GoPro.Camera.mode(mode, submode)

cam.mode(GoPro.Settings.Modes.Burst, GoPro.Settings.Submodes.Burst.Timelapse).then(function () {
    console.log('[gopro mode changed]');
});

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)

cam.status(GoPro.Status.InternalBatteryLevel).then(function (status_value) {
    console.log('[battery level is] = ', status_value);
});

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