Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hls-maker

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hls-maker

HLSMaker is a library that helps create HLS (HTTP Live Streaming) video segments from a source file. HLS is a protocol for distributing video over the internet.

  • 1.2.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
20
increased by150%
Maintainers
1
Weekly downloads
 
Created
Source

HLSMaker

HLSMaker is a library that helps create HLS (HTTP Live Streaming) video segments from a source file. HLS is a protocol for distributing video over the internet.

Installation

Install the library from npm:

npm install hls-maker

Usage

Using Promises

import { HLSMaker, HLSMakerConfig } from 'hls-maker';

const options: HLSMakerConfig = {
    sourceFilePath: 'path/to/source/video.mp4',
    // Other options as per your requirements
};

const hlsMaker = new HLSMaker(options);

// Start the conversion process
hlsMaker.conversion(progress => {
    console.log(`Progress: ${progress.percent}%`);
}).then(() => {
    console.log('Conversion completed');
}).catch(error => {
    console.error('Error:', error);
});

Using async/await

import { HLSMaker, HLSMakerConfig } from 'hls-maker';

const options: HLSMakerConfig = {
    sourceFilePath: 'path/to/source/video.mp4',
    // Other options as per your requirements
};

async function convertVideo() {
    const hlsMaker = new HLSMaker(options);

    try {
        await hlsMaker.conversion();
        console.log('Conversion completed');
    } catch (error) {
        console.error('Error:', error);
    }
}

convertVideo();

Concatenating HLS Streams

You can concatenate HLS streams using the concat method. This method combines multiple HLS streams into a single stream.

Using callback function

import { HLSMaker, ConcatConfig } from 'hls-maker';

const options: ConcatConfig = {
    sourceFilePath: 'path/to/first/video.mp4',
    hlsManifestPath: 'path/to/concatenated/output.m3u8',
    isLast: true // Set to true if this is the last stream in the sequence
};

HLSMaker.concat(options, function (process) {
    console.log("Processing", process);
});

Using async/await

import { HLSMaker, ConcatConfig } from 'hls-maker';

const options: ConcatConfig = {
    sourceFilePath: 'path/to/first/video.m3u8',
    hlsManifestPath: 'path/to/concatenated/output.m3u8',
    isLast: true // Set to true if this is the last stream in the sequence
};

async function concatVideos() {
    try {
        await HLSMaker.concat(options);
        console.log('Concatenation completed');
    } catch (error) {
        console.error('Error:', error);
    }
}

concatVideos();

Insert HLS Streams

You can insert HLS streams using the insert method. This method combines multiple HLS streams into a single stream.

await HLSMaker.insert({
    hlsManifestPath: 'path/to/first/output.m3u8',
    sourceHlsManifestPath: 'path/to/source/input.m3u8',
    spliceIndex: 10 // insert from segment index
    splicePercent: 30// insert from segment percent
});

Options

HLSMakerConfig

  • sourceFilePath (required): Path to the source file.
  • hlsStartTime: Start time for segmenting in HLS.
  • hlsDuration: Duration of the segment for HLS.
  • hlsManifestPath: Path to the HLS manifest file after segmenting.
  • hlsSegmentDuration: Duration of each segment (in seconds).
  • hlsListSize: Manifest list size.
  • appendMode (required): Append mode for segments.
  • endlessMode (required): Endless mode (no termination).

ConcatConfig

  • sourceFilePath (required): Path to the source file of the first segment.
  • hlsManifestPath (required): Path to the output manifest file after concatenation.
  • isLast (required): Set to true if this is the last stream in the sequence.

Support

Contact the author: hunglsxx@gmail.com

License

This library is released under the MIT License.

Keywords

FAQs

Package last updated on 14 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc