Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/Eyevinn/hls-ts-js

HLS MPEG-TS parser library in Javascript
https://github.com/Eyevinn/hls-ts-js

hls mpeg streaming video

Last synced: 3 months ago
JSON representation

HLS MPEG-TS parser library in Javascript

Awesome Lists containing this project

README

        

[![Build Status](https://travis-ci.org/Eyevinn/hls-ts-js.svg?branch=master)](https://travis-ci.org/Eyevinn/hls-ts-js)
[![Coverage Status](https://coveralls.io/repos/github/Eyevinn/hls-ts-js/badge.svg?branch=master)](https://coveralls.io/github/Eyevinn/hls-ts-js?branch=master)

A Javascript library to parse Apple HLS MPEG Transport Stream segments

## Usage (Node JS)

```
npm install --save hls-ts
```

The library implements the `Writable` stream interface and acts a a "sink". For example to download
and parse an HLS MPEG Transport Stream segment:

```
const request = require("request");
const hlsTs = require("hls-ts");

request.get("http://example.com/seg10.ts")
.pipe(hlsTs.parse())
.on("finish", function() {

// Obtain all programs found in the Transport Stream
const programs = hlsTs.programs;

// Obtain all packets for a specific program stream
const avcPackets = hlsTs.getPacketsByProgramType("avc");

// Obtain the payload for a program stream
const avcPayload = hlsTs.getDataStreamByProgramType("avc");

// where avcPayload.data is a Uint8Array
const avcParser = hlsTs.createAvcParser(avcPayload);

// Obtain NAL units
const nalUnits = avcParser.getNalUnits();
});
```

## Usage (Browser version)

```

var xhr = new XMLHttpRequest();
var url = "http://example.com/hls/seg-10s.ts";
var parser = new window.HlsTs({ debug: false });
xhr.responseType = "arraybuffer";
xhr.onloadend = function() {
var buffer = xhr.response;
var data = new Uint8Array(buffer);
parser.parse(data).then(function() {
// Obtain all programs found in the Transport Stream
var programs = parser.getPrograms();

// Obtain all packets for a specific program stream
var avcPackets = parser.getPacketsByProgramType("avc");

// Obtain the payload for a program stream
var avcPayload = parser.getDataStreamByProgramType("avc");

// where avcPayload.data is a Uint8Array
var avcParser = parser.createAvcParser(avcPayload);

// Obtain NAL units
var nalUnits = avcParser.getNalUnits();
}).catch(function(err) { console.error(err.message); }).then(done);
};
xhr.open("GET", url);
xhr.send();

```

## API Documentation

Find API documentation here: https://inspect.eyevinn.technology/docs/index.html

## Contributing
All contributions are welcome but before you submit a Pull Request make sure you follow the same
code conventions and that you have written unit tests

## About Eyevinn Technology

Eyevinn Technology is an independent consultant firm specialized in video and streaming. Independent in a way that we are not commercially tied to any platform or technology vendor.

At Eyevinn, every software developer consultant has a dedicated budget reserved for open source development and contribution to the open source community. This give us room for innovation, team building and personal competence development. And also gives us as a company a way to contribute back to the open source community.

Want to know more about Eyevinn and how it is to work here. Contact us at [email protected]!