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

@augmentality/node-omx

v1.0.11

Published

[![npm version](https://badge.fury.io/js/%40augmentality%2Fnode-omx.svg)](https://badge.fury.io/js/%40caspertech%2Fnode-omx) [![Known Vulnerabilities](https://snyk.io/test/npm/@augmentality/node-omx/badge.svg)](https://snyk.io/test/npm/@augmentality/node-

Downloads

16

Readme

node-omx

npm version Known Vulnerabilities Dependencies

A Node.JS video player for the Raspberry Pi (and other devices using Broadcom's OpenMax-based Multi-Media Abstraction Layer API)

This is a compiled module for NodeJS which provides hardware-accelerated video and audio playback on the Pi. Everything is built-in, it doesn't shell out to other applications.

Prerequisites

Please check npm -v to make sure you have [email protected] or higher. The version of npm included with Raspbian is, of course, hopelessly out of date and can't compile this module.

For raspbian:

apt-get install build-essential cmake libavutil-dev libavcodec-dev libswresample-dev libavformat-dev

Install

npm install --save @augmentality/node-omx

Features

  • Asynchronous loading, playback and control
  • Instant start (once loaded)
  • Network or local playback
  • Seamless looping with a/v sync
  • Pause / Resume
  • Get playback time
  • Callbacks for play state
  • Seamless switching between videos with multiple instances
  • Supports mp4, mkv, mov, or any container supported by ffmpeg

Supported Platforms

Any device supporting Broadcom's OpenMax-based Multi-Media Abstraction Layer API.

For convenience, on unsupported platforms, the module will still build and will output placeholder messages instead of playing media.

Usage Example

Javascript

const omx = require('@augmentality/node-omx');
const readline = require('readline');

readline.emitKeypressEvents(process.stdin);

let state = 0;
async function run()
{
    const n = new omx.Player();


    n.onPlaybackState.subscribe((pState) =>
    {
        state = pState;
        switch(state)
        {
            case 0:
                console.log('Stopped');
                break;
            case 1:
                console.log('File loaded');
                break;
            case 2:
                console.log('Playing');
                break;
            case 3:
                console.log('Paused');
                break;
        }
    });

    await n.open('http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4');
    n.play();
    n.setLoop(true); // Enable seamless looping

    setInterval(() =>
    {
        if (state > 0)
        {
            console.log('Playback position: ' + n.getTime());
        }
    }, 1000);

    let speed = 1.0;
    let paused = false;
    process.stdin.setRawMode(true);
    process.stdin.on('keypress', (str, key) =>
    {
        if (key.ctrl && key.name === 'q')
        {
            process.exit();
        }
        else
        {
            switch(key.name)
            {
                case 'up':
                    speed += 0.01;
                    console.log('Playback speed: ' + speed);
                    n.setSpeed(speed);
                    break;
                case 'down':
                    speed -= 0.01;
                    console.log('Playback speed: ' + speed);
                    n.setSpeed(speed);
                    break;
                case 'space':
                    if (!paused)
                    {
                        n.pause();
                        paused = true;
                    }
                    else
                    {
                        n.play();
                        paused = false;
                    }
                    break;
            }
        }
    });
}
run().then({});

Caveats

  • A read-ahead buffer is implemented to help smooth playback. If you disable looping, the reader may have already looped, in which case playback will end at the end of the next run.
  • Only H264 video is supported at present.
  • Looping is not possible when playing h264 annex-b (raw H264). Mux into a container if you need this.