@decipherindustries/flazhback-hls-tools
v1.0.3
Published
A set of tools to work with HLS streams
Downloads
6
Readme
HLS-Tools
Various tools for working with HLS streams. At the moment it only supports generating a new HLS stream based on one or more existing HLS streams.
Installation
% npm install --save flazhback-hls-tools
Usage
The example below creates a new HLS stream from two other streams - defined by the array in clips
. source
references the stream in the sources
list. start
and end
indicate the time codes to select from the respective streams.
The code assumes that the .ts
files in the source streams are named index0.ts
, index1.ts
, ...
, indexN.ts
and the HLS index file is named index.m3u8
.
'use strict'
const join = require('path').join
const HLSTools = require('flazhback-hls-tools')
const targetDir = join(__dirname, 'data/streams/stream_id')
const sources = [
join(__dirname, 'data/streams/stream_0'),
join(__dirname, 'data/streams/stream_1'),
]
const clips = [
{
source: 0,
start: 100, // seconds
end: 400, // seconds
duration: 300, // seconds
},
{
source: 1,
start: 50, // seconds
end: 200, // seconds
duration: 150, // seconds
}
]
HLSTools
.generateHlsFromPlaylist(sources, targetDir, clips)
.then(createdHlsPath => {
console.log(createdHlsPath)
})
.catch(err => {
console.error(err.message)
})