Giter Club home page Giter Club logo

node-m3u8's Introduction

m3u8

node-m3u8 is a streaming m3u8 parser tailored for dealing with Apple's HTTP Live Streaming protocol. It may work for other m3u files, but I have not tested it for those uses.

example

var m3u8 = require('m3u8');
var fs   = require('fs');

var parser = m3u8.createStream();
var file   = fs.createReadStream('/path/to/file.m3u8');
file.pipe(parser);

parser.on('item', function(item) {
  // emits PlaylistItem, MediaItem, StreamItem, and IframeStreamItem
});
parser.on('m3u', function(m3u) {
  // fully parsed m3u file
});

All items and the m3u object have toString() methods for conversion to m3u8. Attributes and properties have getter/setters on m3u and item objects:

parser.on('item', function(item) {
  var duration = item.get('bandwidth');
  item.set('uri', 'http://example.com/' + item.get('uri'));
});

The M3U and Item objects are available on m3u8:

var m3u8 = require('m3u8');

var m3u = m3u8.M3U.create();
m3u.addPlaylistItem({
  duration : 10,
  uri      : 'file'
});

See tests for more usage patterns.

node-m3u8's People

Contributors

astroza avatar bog avatar chriswiggins avatar eirikurn avatar eladbenedict avatar jhurliman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-m3u8's Issues

Is there a way to create a variant/master playlist with this lib?

I am trying to develop an HLS VoD backend API. I already built the algorithm to create the different segment playlists for each quality that I want to deliver. I need to create a variant/master playlist to glue them together based on the bandwidth. Can this lib do something like variantplaylistcreator?

Filtering streamItems

I need to create several m3u8 files that requires different orderings and filterings of StreamItems of an existing m3u8.

I'm a little puzzled how to manipulate your internal data structure.

Do I create my individual playlists, e.g.

var newPlaylist = m3u8.M3U.create()
newPlaylist.addStreamItem(..

But how do I filter m3u.items.StreamItem by a name that I want to include into my new playlist?

How this works?

I am looking for a simple js file which gives me multiple links(based of bandwith) by parsing m3u8 file.

Unreachable Code in parser.js

I was trying to figure out what line 49 in parser.js was doing as it doesn't make sense to me. Looking into it further it looks like the condition in the if statement will never be true anyway, as the uri property will only ever get set on the .properties object not .attributes.

if (this.currentItem.attributes.uri != undefined) {

I'm on windows and tried to run the tests with ./node_modules/.bin/mocha --reporter list test/*.js test/acceptance/*.js but get an error saying Error: Cannot find module 'should'

unknown keys

Handling value: 233200  for unknown key: average-bandwidth
Handling value: 398200  for unknown key: average-bandwidth
Handling value: 605000  for unknown key: average-bandwidth
Handling value: 840400  for unknown key: average-bandwidth
Handling value: 1317800  for unknown key: average-bandwidth
Handling value: 2233000  for unknown key: average-bandwidth
Handling value: 3520000  for unknown key: average-bandwidth
Handling value: 5500000  for unknown key: average-bandwidth
Handling value: "CC1"  for unknown key: instream-id
Handling value: "cc"  for unknown key: closed-captions
Handling value: "cc"  for unknown key: closed-captions
Handling value: "cc"  for unknown key: closed-captions
Handling value: "cc"  for unknown key: closed-captions
Handling value: 30.000  for unknown key: frame-rate
Handling value: 398585  for unknown key: average-bandwidth
Handling value: 30.000  for unknown key: frame-rate
Handling value: 682203  for unknown key: average-bandwidth
Handling value: 30.000  for unknown key: frame-rate
Handling value: 1200819  for unknown key: average-bandwidth
Handling value: 30.000  for unknown key: frame-rate
Handling value: 2537877  for unknown key: average-bandwidth
Handling value: 15.000  for unknown key: frame-rate
Handling value: 114966  for unknown key: average-bandwidth
Handling value: 30.000  for unknown key: frame-rate
Handling value: 220310  for unknown key: average-bandwidth

Serialization/Deserialization

I'm probably missing something obvious here, but how to I serialize and deserialize after I have parsed an m3u8 file? Is that possible?

Add support for creating non-VOD playlists

The following block of code:

if (this.items.PlaylistItem.length) {
  output.push(this.items.PlaylistItem.map(itemToString).join('\n'));
  output.push('#EXT-X-ENDLIST\n');
} else {

Turns every playlist into a VOD playlist. EVENT playlists and sliding window playlists have playlist items but do not end with EXT-X-ENDLIST.

parse a remote playlist?

I'd like to parse a remote playlist for a stream that matches a specific bandwidth and/or resolution

Given http://remote-cdn/index.m3u8

#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1896000,AUDIO="master_broadcast"
http://remote-cdn/1896k.m3u8

I'd like to be able to search by BANDWIDTH or RESOLUTION

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.