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

m3u8stream

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

m3u8stream

Reads segments from a m3u8 or dash playlist into a consumable stream.

  • 0.8.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
171K
decreased by-13.32%
Maintainers
1
Weekly downloads
 
Created

What is m3u8stream?

The m3u8stream npm package is used to create a readable stream from an M3U8 playlist, which is commonly used for HTTP Live Streaming (HLS). This allows you to download or process media streams in a programmatic way.

What are m3u8stream's main functionalities?

Stream from M3U8 URL

This feature allows you to create a readable stream from an M3U8 URL and pipe it to a writable stream, such as a file. In this example, the media stream from the M3U8 URL is saved to 'output.ts'.

const m3u8stream = require('m3u8stream');
const fs = require('fs');

const stream = m3u8stream('http://example.com/playlist.m3u8');
stream.pipe(fs.createWriteStream('output.ts'));

Handle Stream Events

This feature allows you to handle various events emitted by the stream, such as 'progress' and 'end'. This can be useful for tracking the download progress and performing actions when the download is complete.

const m3u8stream = require('m3u8stream');

const stream = m3u8stream('http://example.com/playlist.m3u8');

stream.on('progress', (segment, totalSegments, downloaded) => {
  console.log(`Downloading segment ${segment.num} of ${totalSegments}`);
  console.log(`Downloaded: ${downloaded} bytes`);
});

stream.on('end', () => {
  console.log('Download complete');
});

Custom Request Options

This feature allows you to pass custom request options, such as headers, to the underlying HTTP requests made by m3u8stream. In this example, a custom User-Agent header is set for the requests.

const m3u8stream = require('m3u8stream');
const fs = require('fs');

const stream = m3u8stream('http://example.com/playlist.m3u8', {
  requestOptions: {
    headers: {
      'User-Agent': 'my-custom-user-agent'
    }
  }
});

stream.pipe(fs.createWriteStream('output.ts'));

Other packages similar to m3u8stream

Keywords

FAQs

Package last updated on 09 Jan 2022

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