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

hls-stream-creator

v1.1.0

Published

Create an M3U8 playlist from media file using FFMPEG

Downloads

6

Readme

HLS Stream Creator - Node.js

NPM GitHub package.json version CircleCI

Create an M3U8 playlist from media file using FFMPEG.

Installation

npm i hls-stream-creator

Prerequisites

This package using fluent-ffmpeg so ffmpeg must be installed it requires at least ffmpeg 0.9 to work.

You must also have ffprobe installed (it comes with ffmpeg in most distributions).

Windows users: most probably ffmpeg and ffprobe will not be in your %PATH, so you must set %FFMPEG_PATH and %FFPROBE_PATH.

Debian/Ubuntu users: the official repositories have the ffmpeg/ffprobe executable in the libav-tools package, and they are actually rebranded avconv/avprobe executables (avconv is a fork of ffmpeg). They should be mostly compatible, but should you encounter any issue, you may want to use the real ffmpeg instead. You can either compile it from source or find a pre-built .deb package at https://ffmpeg.org/download.html (For Ubuntu, the ppa:mc3man/trusty-media PPA provides recent builds).

Usage

const hlsStreamCreator = require('hls-stream-creator');

(async () => {
  const settings = {
    renditions: [
      {
        resolution: {
          width: 1920,
          height: 1080,
        },
        bitrate: 8000,
        audioRate: 320,
      },
      {
        resolution: {
          width: 1280,
          height: 720,
        },
        bitrate: 4000,
        audioRate: 192,
      },
    ],
    printLogs: true
  };
  
  try {
    await hlsStreamCreator('./sample.mkv', './output', settings);
  } catch (err) {
    console.log(`Oops we got an error, err: ${err}`);
  }
})();

API

hlsStreamCreator(src, targetDir, settings?)

Returns a Promise<void>.

src

Type: string

Media file.

If media file does not exists will be thrown an error.

targetDir

Type: string

Destination directory which will hold all the mpeg-ts files with m3u8 files.

settings

Type: object

In addition, you can specify the below options.

renditions

Type:

{
  resolution: {
    width: number, // example: 1920
    height: number, // example: 1080
  },
  bitrate: number, // example: 8000
  audioRate: number, // example: 320
}

Default: []

Must be at least one rendition if not will be thrown an error.

speed

Type: Speed | string
Default: veryfast

The speed will be for making the stream files.

Can be: 'ultrafast' || 'superfast' || 'veryfast' || 'faster' || 'fast' || 'medium' || 'slow' || 'slower' || 'veryslow'

videoCodec

Type: string
Default: libx264

Recommended not to change this value because the default value libx264 is supported in all browsers.

audioCodec

Type: string
Default: aac

Recommended not to change this value because the default value aac is supported in all browsers.

printLogs

Type: boolean
Default: true

In case we want to see the process logs of ffmpeg.

License

MIT