npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@videojs/plugin-concat

v1.0.0

Published

Concatenate videos for playback in a Video.js player

Downloads

822

Readme

videojs-concat

Concatenate videos for playback in a Video.js player

Table of Contents

Requirements

Note that this plugin requires the master branch of VHS.

Test Page

To use the test page, clone VHS, run:

npm install
npm run build
npm link

Then in the plugin-concat directory, run:

npm link @videojs/http-streaming

Installation

npm install --save @videojs/plugin-concat

Usage

To include videojs-concat on your website or web application, use any of the following methods.

<script> Tag

This is the simplest case. Get the script in whatever way you prefer and include the plugin after you include video.js, so that the videojs global is available.

<script src="//path/to/video.min.js"></script>
<script src="//path/to/videojs-plugin-concat.min.js"></script>
<script>
  var player = videojs('my-video');

  player.concat(options);
</script>

Browserify/CommonJS

When using with Browserify, install videojs-concat via npm and require the plugin as you would any other module.

var videojs = require('video.js');

// The actual plugin function is exported by this module, but it is also
// attached to the `Player.prototype`; so, there is no need to assign it
// to a variable.
require('@videojs/plugin-concat');

var player = videojs('my-video');

player.concat();

RequireJS/AMD

When using with RequireJS (or another AMD library), get the script in whatever way you prefer and require the plugin as you normally would:

require(['video.js', '@videojs/plugin-concat'], function(videojs) {
  var player = videojs('my-video');

  player.concat(options);
});

Method

videojs-concat uses the standard VHS manifest parsers (m3u8-parser and mpd-parser at the moment) to create manifest objects from the downloaded manifests, then merges the JSON objects. The result can be passed as JSON via a data URI to VHS.

To use videojs-concat, all that needs to be done is to call the function videojs.concat.concatenateVideos and wait for the asynchronous operation to finish. The operation is asynchronous to allow for downloading of the manifests.

Limitations

  • Renditions must have both audio and video (though demuxed is supported in addition to muxed).
  • Only HLS and DASH are supported (at the moment).
  • Only one rendition is used per source.
  • Alternate audio is not supported (except demuxed with default audio playlists).
  • WebVTT subtitle playlists are not supported.

DRM

DRM is supported via videojs-contrib-eme.

To use DRM encrypted sources, add keySystems information to each encrypted manifest object in the same way as would be done for videojs-contrib-eme. See the README for details.

Normally, licenses are requested for a video when segments are appended to the browser and the browser needs to decrypt the video. However, with multiple videos being concatenated, determining which key system information to use for the license request becomes challenging. Therefore, videojs-concat returns a function, initializeKeySystems(player) which sets up all of the key systems at once. initializeKeySystems(player) should be called after setting the source on the player. See [HLS Widevine and DASH Widevine] for an example.

Examples

Two of the same DASH source

player.concat({
  manifests: [{
    url: 'https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd',
    mimeType: 'application/dash+xml'
  }, {
    url: 'https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd',
    mimeType: 'application/dash+xml'
  }],
  targetVerticalResolution: 720,
  callback: (err, result) => {
    if (err) {
      console.error(err);
      return;
    }
    console.log(result);
    player.src({
      src: `data:application/vnd.videojs.vhs+json,${JSON.stringify(result.manifestObject)}`,
      type: 'application/vnd.videojs.vhs+json'
    });
  }
});

Two of the same HLS source

player.concat({
  manifests: [{
    url: 'https://s3.amazonaws.com/_bc_dml/example-content/bipbop-advanced/bipbop_16x9_variant.m3u8',
    mimeType: 'application/x-mpegURL'
  }, {
    url: 'https://s3.amazonaws.com/_bc_dml/example-content/bipbop-advanced/bipbop_16x9_variant.m3u8',
    mimeType: 'application/x-mpegURL'
  }],
  targetVerticalResolution: 720,
  callback: (err, result) => {
    if (err) {
      console.error(err);
      return;
    }
    console.log(result);
    player.src({
      src: `data:application/vnd.videojs.vhs+json,${JSON.stringify(result.manifestObject)}`,
      type: 'application/vnd.videojs.vhs+json'
    });
  }
});

Two of the same demuxed HLS source

player.concat({
  manifests: [{
    url: 'http://storage.googleapis.com/shaka-demo-assets/angel-one-hls/hls.m3u8',
    mimeType: 'application/x-mpegURL'
  }, {
    url: 'http://storage.googleapis.com/shaka-demo-assets/angel-one-hls/hls.m3u8',
    mimeType: 'application/x-mpegURL'
  }],
  targetVerticalResolution: 720,
  callback: (err, result) => {
    if (err) {
      console.error(err);
      return;
    }
    console.log(result);
    player.src({
      src: `data:application/vnd.videojs.vhs+json,${JSON.stringify(result.manifestObject)}`,
      type: 'application/vnd.videojs.vhs+json'
    });
  }
});

Demuxed HLS and DASH

player.concat({
  manifests: [{
    url: 'http://storage.googleapis.com/shaka-demo-assets/angel-one-hls/hls.m3u8',
    mimeType: 'application/x-mpegURL'
  }, {
    url: 'https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd',
    mimeType: 'application/dash+xml'
  }],
  targetVerticalResolution: 720,
  callback: (err, result) => {
    if (err) {
      console.error(err);
      return;
    }
    console.log(result);
    player.src({
      src: `data:application/vnd.videojs.vhs+json,${JSON.stringify(result.manifestObject)}`,
      type: 'application/vnd.videojs.vhs+json'
    });
  }
});

HLS Widevine and DASH Widevine

// initialize videojs-conrib-eme if it hasn't been initialized already
player.eme();
player.concat({
  manifests: [{
    url: 'https://amssamples.streaming.mediaservices.windows.net/622b189f-ec39-43f2-93a2-201ac4e31ce1/BigBuckBunny.ism/manifest(format=mpd-time-csf)',
    mimeType: 'application/dash+xml',
    keySystems: {
      'com.widevine.alpha': 'https://amssamples.keydelivery.mediaservices.windows.net/Widevine/?KID=1ab45440-532c-4399-94dc-5c5ad9584bac'
    }
  }, {
    url: 'https://storage.googleapis.com/shaka-demo-assets/angel-one-widevine-hls/hls.m3u8',
    mimeType: 'application/x-mpegURL',
    keySystems: {
      'com.widevine.alpha': 'https://cwip-shaka-proxy.appspot.com/no_auth'
    }
  }],
  targetVerticalResolution: 720,
  callback: (err, result) => {
    if (err) {
      console.error(err);
      return;
    }
    console.log(result);
    player.src({
      src: `data:application/vnd.videojs.vhs+json,${JSON.stringify(result.manifestObject)}`,
      type: 'application/vnd.videojs.vhs+json'
    });
    result.initializeKeySystems(player);
  }
});

License

Apache-2.0. Copyright (c) Brightcove, Inc