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

livepeer-node

v1.0.1

Published

Livepeer API wrapper for Node projects

Downloads

8

Readme

Livepeer Node

Livepeer API wrapper for Node projects, supporting for streams and sessions.

The Stream is the core building block of the livepeer.com platform. A livepeer.com stream is a unique object with configuration data and metadata about all live stream sessions associated with it.

The Session is a single live streaming session. It is an especially important Livepeer.com API object if need to reference recorded live stream sessions.

This library is intended to provide Livepeer API convenience methods for applications written in server-side Javascript. Please note that this package uses Livepeer API keys and is intended to be used in server-side code only.

Not familiar with Livepeer? Check out https://livepeer.org/ for more information.

Documentation

See the Livepeer docs

Installation

npm install livepeer-node --save

or

yarn add livepeer-node

Usage

To start, you will need to get API key for Livepeer. For more information on where to get an API key, visit https://livepeer.com/app/user/keys

Require the livepeer-node npm module and create a Livepeer instance. Your Livepeer instance will have some properties such as Stream and Session that allow you to access the Stream and Session APIs.

const Livepeer = require('livepeer-node');
const livepeerObject = new Livepeer({api_key});

Stream

The stream is the core building block of the livepeer.com platform. A livepeer.com stream is a unique object with configuration data and metadata about all live stream sessions associated with it.

| Property | Description | | ------------- | ------------- | | name | Additional identifier for the asset. Often set to a human readable string. This identifier does not need to be unique | | profiles | Transcoding rendition settings. The source will be delivered with the renditions in the HLS and does not need to be redefined in the profiles parameter. If no profiles are defined, only the source will be delivered for playback | | id | Unique identifier for the stream. | | createdAt | Timestamp when the asset was created. Reported in Unix epoch time. | | streamKey | Unique secret key used to form the RTMP ingest URL. ex: RTMP ingest URL - rtmp://rtmp.livepeer.com/live | | playbackId | Unique identifier used to form the playback URL. ex: Playback URL - https://cdn.livepeer.com/hls/{playbackId}/index.m3u8 | | ... | Other object keys. |

- Create a stream

Create a stream with name and profiles.

const stream = await livepeerObject.Stream.create(
    {
    "name": "test_stream", 
    "profiles": [
        {
            "name": "720p",
            "bitrate": 2000000,
            "fps": 30,
            "width": 1280,
            "height": 720
        },
        {
            "name": "480p",
            "bitrate": 1000000,
            "fps": 30,
            "width": 854,
            "height": 480
        },
        {
            "name": "36p",
            "bitrate": 500000,
            "fps": 30,
            "width": 640,
            "height": 360
        },
    ]
    }
);

- Retrieve all streams

Get all streams with the same user (owner of the api_key)

const streams = await livepeerObject.Stream.getAll(streamOnly = 0, isActive = false, record = false);

| Parameter | Description | | ------------- | ------------- | | streamOnly | If 1, exclude historic stream objects | | isActive | If true, get only active stream | | record | If true, get only recorded on stream |

- Retrieve a stream using id

const stream = await livepeerObject.Stream.get(id);

- Turn on/off recording

Turn on/off recording for streams, but not for session or historic stream object (representing a single live stream)

const stream = await livepeerObject.Stream.get(id);
const result = await stream.setRecord(true / false);

- Retrieve a list of sessions

Retrieve a list of sessions of a stream.

const stream = await livepeerObject.Stream.get(id);
const sessions = await stream.getSessions(true / false);

set param as true to get recorded session, otherwise false

Session

The session is a single live streaming session. It is an especially important Livepeer.com API object if need to reference recorded live stream sessions.

| Property | Description | | ------------- | ------------- | | id | Unique identifier for the session. | | sourceSegmentsDuration | Duration in seconds of session source processed. | | record | True means the session is being recorded or was recorded. False means session is not being recorded or was not recorded. | | parentId | Points to a parent stream object. The session’s parentId is the same string as its parent stream’s id. | | recordingStatus | Appears only if record is true. It is either ready when the recorded live stream is available for playback or waiting while the livestream is still active or just recently completed. | | recordingUrl | Appears only if record is true when recordingStatus changes to ready. It’s value is the .m3u8 URL to stream the recorded session | | ... | Other object keys |

- Retrieve a list of sessions

Retrieve a list of sessions with the same User (owner of the api_key).

const sessions = await livepeerObject.Session.getAll();

- Retrieve a session from session id

const session = await livepeerObject.Session.get(id);

Ingest

Get references to stream ingest data centers on the Livepeer network.

| Property | Description | | ------------- | ------------- | | base | Base URL for the playback URL | | ingest | Base URL used to configure the broadcast software. Pair it with a stream object streamKey | | playback | Base URL for HLS playback. Append a stream object playbackId to create the full playback URL |

- Get closest ingest

const ingest = await livepeerObject.Ingest.getClosest()

- Get all ingests

const ingests = await livepeerObject.Ingest.getAll()