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

@m3u8/m3u8-writer

v0.0.1

Published

A node.js module for creating m3u / m3u8 files.

Downloads

5

Readme

node-m3u

A node.js module for creating m3u / m3u8 files. Supported dialects are m3u, extended m3u and http live streaming m3u.

Current Status

This module is still new, but I'm going to use it in production over at transloadit.com next.

Installation

npm install m3u

Usage

The default Writer class can be used to create basic m3u files:

var writer = require('m3u').writer();

// A comment.
writer.comment('I am a comment');

// An empty line.
writer.write(); // blank line

// A playlist item, usually a path or url.
writer.file('foo.mp3');

console.log(writer.toString());

The ExtendedWriter supports all methods of the normal Writer, as well as additional capabilities defined by the extended m3u format.

var writer = require('m3u').extendedWriter();

// Adds a playlist item preceeded by an optional EXTINF tag for the duration.
// and title of the item.
writer.file('bar.mp3');
writer.file('bar.mp3', 23);
writer.file('bar.mp3', 23, 'Artist - Title');

console.log(writer.toString());

The HttpLiveStreamingWriter supports all methods of the ExtendedWriter, as well as additional capabilities defined by Apple:

var writer = require('m3u').httpLiveStreamingWriter();

// EXT-X-TARGETDURATION: Maximum media file duration.
writer.targetDuration(10);

// EXT-X-MEDIA-SEQUENCE: Sequence number of first file (optional).
// (optional)
writer.mediaSequence(0)

// EXT-X-PROGRAM-DATE-TIME: The date of the program's origin, optional.
// (optional)
writer.programDateTime('2011-04-11T21:24:06Z');

// EXT-X-ALLOW-CACHE: Set if the client is allowed to cache this m3u file.
// (optional)
writer.allowCache(true);
writer.allowCache(false);

// EXT-X-PLAYLIST-TYPE: Provides mutability information about the m3u file.
// (optional)
writer.playlistType('EVENT');
writer.playlistType('VOD');

// EXT-X-ENDLIST: Indicates that no more media files will be added to the m3u file.
// (optional)
writer.endlist();

// EXT-X-VERSION: Indicates the compatibility version of the Playlist file.
// (optional)
writer.version(3);

// Adds a playlist as the next item preceeded by an EXT-X-STREAM-INF tag.
writer.playlist('another.m3u', {
  bandwidth: 3000000, // required
  programId: 1,
  codecs: ['avc1.42001e', 'mp4a.40.34'],
  resolution: '640x480',
});

// EXT-X-DISCONTINUITY: Indicates that the player should expect the next video segment to be a different resolution or have a different audio profile than the last.
writer.discontinuity();

console.log(writer.toString());

Todo

I don't have plans for more features at this point, except bug fixes.

Contributing

Stuff I probably won't have time to do myself, and would love to get patches for:

  • Implement the ability to read m3u files
  • Support node.js's writeable stream interface for the writers
  • HttpLiveStreamingWriter#key() (EXT-X-KEY)
  • Support JS date objects for HttpLiveStreamingWriter#programDateTime()

License

node-m3u is licensed under the MIT license.