# plugin-concat **Repository Path**: mirrors_videojs/plugin-concat ## Basic Information - **Project Name**: plugin-concat - **Description**: Concatenate videos for playback by videojs/http-streaming in a Video.js player - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-18 - **Last Updated**: 2026-07-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # videojs-concat Concatenate videos for playback in a Video.js player ## Table of Contents - [Requirements](#requirements) - [Test Page](#test-page) - [Installation](#installation) - [Usage](#usage) - [` ``` ### Browserify/CommonJS When using with Browserify, install videojs-concat via npm and `require` the plugin as you would any other module. ```js 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: ```js 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](https://github.com/videojs/videojs-contrib-eme#setting-options-per-source) 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 ```js 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 ```js 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 ```js 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 ```js 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 ```js // 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 [videojs]: http://videojs.com/ [videojs-contrib-eme]: https://github.com/videojs/videojs-contrib-eme [VHS]: https://github.com/videojs/http-streaming