Code Monkey home page Code Monkey logo

http-streaming's Introduction

VHS Logo consisting of a VHS tape, the Video.js logo and the words VHS

videojs-http-streaming (VHS)

Build Status Slack Status Greenkeeper badge

Play HLS, DASH, and future HTTP streaming protocols with video.js, even where they're not natively supported.

Included in video.js 7 by default! See the video.js 7 blog post

Maintenance Status: Stable

Video.js Compatibility: 7.x, 8.x

Installation

In most cases it is not necessary to separately install http-streaming, as it has been included in the default build of Video.js since version 7.

Only install if you need a specifc combination of video.js and http-streaming versions. If installing separately, use the "core" version of Video.js without the bundled version of http-streaming.

NPM

To install videojs-http-streaming with npm, run

npm install --save @videojs/http-streaming

CDN

Select a version of VHS from the CDN

Releases

Download a release of videojs-http-streaming

Manual Build

Download a copy of this git repository and then follow the steps in Building

Contributing

See CONTRIBUTING.md

Troubleshooting

See our troubleshooting guide

Talk to us

Drop by the Video.js slack.

Getting Started

This library is included in Video.js 7 by default.

Only if need a specific combination of versions of Video.js and VHS you can get a copy of videojs-http-streaming and include it in your page along with video.js. In this case, you should use the "core" build of Video.js, without a bundled VHS:

<video-js id=vid1 width=600 height=300 class="vjs-default-skin" controls>
  <source
     src="https://example.com/index.m3u8"
     type="application/x-mpegURL">
</video-js>
<!-- "core" version of Video.js -->
<script src="video.core.min.js"></script>
<script src="videojs-http-streaming.min.js"></script>
<script>
var player = videojs('vid1');
player.play();
</script>

Is it recommended to use the <video-js> element or load a source with player.src(sourceObject) in order to prevent the video element from playing the source natively where HLS is supported.

Compatibility

The Media Source Extensions API is required for http-streaming to play HLS or MPEG-DASH.

Browsers which support MSE

  • Chrome
  • Firefox
  • Internet Explorer 11 Windows 10 or 8.1

These browsers have some level of native HLS support, however by default the overrideNative option is set to true except on Safari, so MSE playback is used:

  • Chrome Android
  • Firefox Android
  • Edge

Native only

  • Mac Safari
  • iOS Safari

Mac and iPad Safari do have MSE support, but native HLS is recommended

DRM

DRM is supported through videojs-contrib-eme. In order to use DRM, include the videojs-contrib-eme plug, initialize it, and add options to either the plugin or the source.

Detailed option information can be found in the videojs-contrib-eme README.

Documentation

HTTP Live Streaming (HLS) has become a de-facto standard for streaming video on mobile devices thanks to its native support on iOS and Android. There are a number of reasons independent of platform to recommend the format, though:

  • Supports (client-driven) adaptive bitrate selection
  • Delivered over standard HTTP ports
  • Simple, text-based manifest format
  • No proprietary streaming servers required

Unfortunately, all the major desktop browsers except for Safari are missing HLS support. That leaves web developers in the unfortunate position of having to maintain alternate renditions of the same video and potentially having to forego HTML-based video entirely to provide the best desktop viewing experience.

This project addresses that situation by providing a polyfill for HLS on browsers that have support for Media Source Extensions. You can deploy a single HLS stream, code against the regular HTML5 video APIs, and create a fast, high-quality video experience across all the big web device categories.

Check out the full documentation for details on how HLS works and advanced configuration. A description of the adaptive switching behavior is available, too.

videojs-http-streaming supports a bunch of HLS features. Here are some highlights:

  • video-on-demand and live playback modes
  • backup or redundant streams
  • mid-segment quality switching
  • AES-128 segment encryption
  • CEA-608 captions are automatically translated into standard HTML5 caption text tracks
  • In-Manifest WebVTT subtitles are automatically translated into standard HTML5 subtitle tracks
  • Timed ID3 Metadata is automatically translated into HTML5 metedata text tracks
  • Highly customizable adaptive bitrate selection
  • Automatic bandwidth tracking
  • Cross-domain credentials support with CORS
  • Tight integration with video.js and a philosophy of exposing as much as possible with standard HTML APIs
  • Stream with multiple audio tracks and switching to those audio tracks (see the docs folder) for info
  • Media content in fragmented MP4s instead of the MPEG2-TS container format.

For a more complete list of supported and missing features, refer to this doc.

Options

How to use

Initialization

You may pass in an options object to the hls source handler at player initialization. You can pass in options just like you would for other parts of video.js:

// html5 for html hls
videojs(video, {
  html5: {
    vhs: {
      withCredentials: true
    }
  }
});
Source

Some options, such as withCredentials can be passed in to vhs during player.src

var player = videojs('some-video-id');

player.src({
  src: 'https://d2zihajmogu5jn.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8',
  type: 'application/x-mpegURL',
  withCredentials: true
});

List

withCredentials
  • Type: boolean
  • can be used as a source option
  • can be used as an initialization option

When the withCredentials property is set to true, all XHR requests for manifests and segments would have withCredentials set to true as well. This enables storing and passing cookies from the server that the manifests and segments live on. This has some implications on CORS because when set, the Access-Control-Allow-Origin header cannot be set to *, also, the response headers require the addition of Access-Control-Allow-Credentials header which is set to true. See html5rocks's article for more info.

useCueTags
  • Type: boolean
  • can be used as an initialization option

When the useCueTags property is set to true, a text track is created with label 'ad-cues' and kind 'metadata'. The track is then added to player.textTracks(). Changes in active cue may be tracked by following the Video.js cue points API for text tracks. For example:

let textTracks = player.textTracks();
let cuesTrack;

for (let i = 0; i < textTracks.length; i++) {
  if (textTracks[i].label === 'ad-cues') {
    cuesTrack = textTracks[i];
  }
}

cuesTrack.addEventListener('cuechange', function() {
  let activeCues = cuesTrack.activeCues;

  for (let i = 0; i < activeCues.length; i++) {
    let activeCue = activeCues[i];

    console.log('Cue runs from ' + activeCue.startTime +
                ' to ' + activeCue.endTime);
  }
});
parse708captions
  • Type: boolean
  • Default: true
  • can be used as an initialization option

When set to false, 708 captions in the stream are not parsed and will not show up in text track lists or the captions menu.

overrideNative
  • Type: boolean
  • can be used as an initialization option

Try to use videojs-http-streaming even on platforms that provide some level of HLS support natively. There are a number of platforms that technically play back HLS content but aren't very reliable or are missing features like CEA-608 captions support. When overrideNative is true, if the platform supports Media Source Extensions videojs-http-streaming will take over HLS playback to provide a more consistent experience.

// via the constructor
var player = videojs('playerId', {
  html5: {
    vhs: {
      overrideNative: true
    },
    nativeAudioTracks: false,
    nativeVideoTracks: false
  }
});

Since MSE playback may be desirable on all browsers with some native support other than Safari, overrideNative: !videojs.browser.IS_SAFARI could be used.

playlistExclusionDuration
  • Type: number
  • can be used as an initialization option

When the playlistExclusionDuration property is set to a time duration in seconds, if a playlist is excluded, it will be excluded for a period of that customized duration. This enables the exclusion duration to be configured by the user.

maxPlaylistRetries
  • Type: number
  • Default: Infinity
  • can be used as an initialization option

The max number of times that a playlist will retry loading following an error before being indefinitely excluded from the rendition selection algorithm. Note: the number of retry attempts needs to exceed this value before a playlist will be excluded.

bandwidth
  • Type: number
  • can be used as an initialization option

When the bandwidth property is set (bits per second), it will be used in the calculation for initial playlist selection, before more bandwidth information is seen by the player.

useBandwidthFromLocalStorage
  • Type: boolean
  • can be used as an initialization option

If true, bandwidth and throughput values are stored in and retrieved from local storage on startup (for initial rendition selection). This setting is false by default.

enableLowInitialPlaylist
  • Type: boolean
  • can be used as an initialization option

When enableLowInitialPlaylist is set to true, it will be used to select the lowest bitrate playlist initially. This helps to decrease playback start time. This setting is false by default.

limitRenditionByPlayerDimensions
  • Type: boolean
  • can be used as an initialization option

When limitRenditionByPlayerDimensions is set to true, rendition selection logic will take into account the player size and rendition resolutions when making a decision. This setting is true by default.

useDevicePixelRatio
  • Type: boolean
  • can be used as an initialization option.

If true, this will take the device pixel ratio into account when doing rendition switching. This means that if you have a player with the width of 540px in a high density display with a device pixel ratio of 2, a rendition of 1080p will be allowed. This setting is false by default.

customPixelRatio
  • Type: number
  • can be used as an initialization option.

If set, this will take the initial player dimensions and multiply it by a custom ratio when the player automatically selects renditions. This means that if you have a player where the dimension is 540p, with a custom pixel ratio of 2, a rendition of 1080p or a lower rendition closest to this value will be chosen. Additionally, if you have a player where the dimension is 540p, with a custom pixel ratio of 0.5, a rendition of 270p or a lower rendition closest to this value will be chosen. When the custom pixel ratio is 0, the lowest available rendition will be selected.

It is worth noting that if the player dimension multiplied by the custom pixel ratio is greater than any available rendition resolution, a rendition will be selected based on bandwidth, and the player dimension will be disregarded.

limitRenditionByPlayerDimensions must be true in order for this feature to be enabled. This is the default value.

If useDevicePixelRatio is set to true, the custom pixel ratio will be prioritized and overwrite any previous pixel ratio.

allowSeeksWithinUnsafeLiveWindow
  • Type: boolean
  • can be used as a source option

When allowSeeksWithinUnsafeLiveWindow is set to true, if the active playlist is live and a seek is made to a time between the safe live point (end of manifest minus three times the target duration, see the hls spec for details) and the end of the playlist, the seek is allowed, rather than corrected to the safe live point.

This option can help in instances where the live stream's target duration is greater than the segment durations, playback ends up in the unsafe live window, and there are gaps in the content. In this case the player will attempt to seek past the gaps but end up seeking inside of the unsafe range, leading to a correction and seek back into a previously played content.

The property defaults to false.

customTagParsers
  • Type: Array
  • can be used as a source option

With customTagParsers you can pass an array of custom m3u8 tag parser objects. See https://github.com/videojs/m3u8-parser#custom-parsers

customTagMappers
  • Type: Array
  • can be used as a source option

Similar to customTagParsers, with customTagMappers you can pass an array of custom m3u8 tag mapper objects. See https://github.com/videojs/m3u8-parser#custom-parsers

cacheEncryptionKeys
  • Type: boolean
  • can be used as a source option
  • can be used as an initialization option

This option forces the player to cache AES-128 encryption keys internally instead of requesting the key alongside every segment request. This option defaults to false.

handlePartialData
  • Type: boolean,
  • Default: false
  • Use partial appends in the transmuxer and segment loader
liveRangeSafeTimeDelta
  • Type: number,
  • Default: SAFE_TIME_DELTA
  • Allow to re-define length (in seconds) of time delta when you compare current time and the end of the buffered range.
useNetworkInformationApi
  • Type: boolean,
  • Default: false
  • Use window.networkInformation.downlink to estimate the network's bandwidth. Per mdn, The value is never greater than 10 Mbps, as a non-standard anti-fingerprinting measure. Given this, if bandwidth estimates from both the player and networkInfo are >= 10 Mbps, the player will use the larger of the two values as its bandwidth estimate.
useDtsForTimestampOffset
  • Type: boolean,
  • Default: false
  • Use Decode Timestamp instead of Presentation Timestamp for timestampOffset calculation. This option was introduced to align with DTS-based browsers. This option affects only transmuxed data (eg: transport stream). For more info please check the following issue.
useForcedSubtitles
  • Type: boolean
  • Default: false
  • can be used as a source option
  • can be used as an initialization option

If true, this option allows the player to display forced subtitles. When available, forced subtitles allow to translate foreign language dialogues or images containing foreign language characters.

captionServices
  • Type: object
  • Default: undefined
  • Provide extra information, like a label or a language, for instream (608 and 708) captions.

The captionServices options object has properties that map to the caption services. Each property is an object itself that includes several properties, like a label or language.

For 608 captions, the service names are CC1, CC2, CC3, and CC4. For 708 captions, the service names are SERVICEn where n is a digit between 1 and 63.

For 708 caption services, you may additionally provide an encoding value that will be used by the transmuxer to decode the captions using an instance of TextDecoder. This is to permit and is required for legacy multi-byte encodings. Please review the TextDecoder documentation for accepted encoding labels.

Format
{
  vhs: {
    captionServices: {
      [serviceName]: {
        language: String, // optional
        label: String, // optional
        default: boolean, // optional,
        encoding: String // optional, 708 services only
      }
    }
  }
}
Example
{
  vhs: {
    captionServices: {
      CC1: {
        language: 'en',
        label: 'English'
      },
      SERVICE1: {
        langauge: 'kr',
        label: 'Korean',
        encoding: 'euc-kr'
        default: true,
      }
    }
  }
}

Runtime Properties

Runtime properties are attached to the tech object when HLS is in use. You can get a reference to the VHS source handler like this:

var vhs = player.tech().vhs;

If you were thinking about modifying runtime properties in a video.js plugin, we'd recommend you avoid it. Your plugin won't work with videos that don't use videojs-http-streaming and the best plugins work across all the media types that video.js supports. If you're deploying videojs-http-streaming on your own website and want to make a couple tweaks though, go for it!

vhs.playlists.main

Type: object

An object representing the parsed main playlist. If a media playlist is loaded directly, a main playlist with only one entry will be created.

vhs.playlists.media

Type: function

A function that can be used to retrieve or modify the currently active media playlist. The active media playlist is referred to when additional video data needs to be downloaded. Calling this function with no arguments returns the parsed playlist object for the active media playlist. Calling this function with a playlist object from the main playlist or a URI string as specified in the main playlist will kick off an asynchronous load of the specified media playlist. Once it has been retreived, it will become the active media playlist.

vhs.systemBandwidth

Type: number

systemBandwidth is a combination of two serial processes' bitrates. The first is the network bitrate provided by bandwidth and the second is the bitrate of the entire process after that (decryption, transmuxing, and appending) provided by throughput. This value is used by the default implementation of selectPlaylist to select an appropriate bitrate to play.

Since the two process are serial, the overall system bandwidth is given by: systemBandwidth = 1 / (1 / bandwidth + 1 / throughput)

vhs.bandwidth

Type: number

The number of bits downloaded per second in the last segment download.

Before the first video segment has been downloaded, it's hard to estimate bandwidth accurately. The HLS tech uses a starting value of 4194304 or 0.5 MB/s. If you have a more accurate source of bandwidth information, you can override this value as soon as the HLS tech has loaded to provide an initial bandwidth estimate.

vhs.throughput

Type: number

The number of bits decrypted, transmuxed, and appended per second as a cumulative average across active processing time.

vhs.selectPlaylist

Type: function

A function that returns the media playlist object to use to download the next segment. It is invoked by the tech immediately before a new segment is downloaded. You can override this function to provide your adaptive streaming logic. You must, however, be sure to return a valid media playlist object that is present in player.tech().vhs.main.

Overridding this function with your own is very powerful but is overkill for many purposes. Most of the time, you should use the much simpler function below to selectively enable or disable a playlist from the adaptive streaming logic.

vhs.representations

Type: function

It is recommended to include the videojs-contrib-quality-levels plugin to your page so that videojs-http-streaming will automatically populate the QualityLevelList exposed on the player by the plugin. You can access this list by calling player.qualityLevels(). See the videojs-contrib-quality-levels project page for more information on how to use the api.

Example, only enabling representations with a width greater than or equal to 720:

var qualityLevels = player.qualityLevels();

for (var i = 0; i < qualityLevels.length; i++) {
  var quality = qualityLevels[i];
  if (quality.width >= 720) {
    quality.enabled = true;
  } else {
    quality.enabled = false;
  }
}

If including videojs-contrib-quality-levels is not an option, you can use the representations api. To get all of the available representations, call the representations() method on player.tech().vhs. This will return a list of plain objects, each with width, height, bandwidth, and id properties, and an enabled() method.

player.tech().vhs.representations();

To see whether the representation is enabled or disabled, call its enabled() method with no arguments. To set whether it is enabled/disabled, call its enabled() method and pass in a boolean value. Calling <representation>.enabled(true) will allow the adaptive bitrate algorithm to select the representation while calling <representation>.enabled(false) will disallow any selection of that representation.

Example, only enabling representations with a width greater than or equal to 720:

player.tech().vhs.representations().forEach(function(rep) {
  if (rep.width >= 720) {
    rep.enabled(true);
  } else {
    rep.enabled(false);
  }
});

vhs.xhr

Type: function

The xhr function that is used by VHS internally is exposed on the per- player vhs object. While it is possible, we do not recommend replacing the function with your own implementation. Instead, xhr provides the ability to specify onRequest and onResponse hooks which each take a callback function as a parameter, as well as offRequest and offResponse functions which can remove a callback function from the onRequest or onResponse Set. An xhr-hooks-ready event is fired from a player when per-player hooks are ready to be added or removed. This will ensure player specific hooks are set prior to any manifest or segment requests.

The onRequest(callback) function takes a callback function that will pass an xhr options Object to that callback. These callbacks are called synchronously, in the order registered and act as pre-request hooks for modifying the xhr options Object prior to making a request.

Note: This callback MUST return an options Object as the xhr wrapper and each onRequest hook receives the returned options as a parameter.

Example:

player.on('xhr-hooks-ready', () => {
  const playerRequestHook = (options) => {
    return {
      uri: 'https://new.options.uri'
    };
  };
  player.tech().vhs.xhr.onRequest(playerRequestHook);
});

If access to the xhr Object is required prior to the xhr.send call, an options.beforeSend callback can be set within an onRequest callback function that will pass the xhr Object as a parameter and will be called immediately prior to xhr.send.

Example:

player.on('xhr-hooks-ready', () => {
  const playerXhrRequestHook = (options) => {
    options.beforeSend = (xhr) => {
      xhr.setRequestHeader('foo', 'bar');
    };
    return options;
  };
  player.tech().vhs.xhr.onRequest(playerXhrRequestHook);
});

The onResponse(callback) function takes a callback function that will pass the xhr request, error, and response Objects to that callback. These callbacks are called in the order registered and act as post-request hooks for gathering data from the xhr request, error and response Objects. onResponse callbacks do not require a return value, the parameters are passed to each subsequent callback by reference.

Example:

player.on('xhr-hooks-ready', () => {
  const playerResponseHook = (request, error, response) => {
    const bar = response.headers.foo;
  };
  player.tech().vhs.xhr.onResponse(playerResponseHook);
});

The offRequest function takes a callback function, and will remove that function from the collection of onRequest hooks if it exists.

Example:

player.on('xhr-hooks-ready', () => {
  player.tech().vhs.xhr.offRequest(playerRequestHook);
});

The offResponse function takes a callback function, and will remove that function from the collection of offResponse hooks if it exists.

Example:

player.on('xhr-hooks-ready', () => {
  player.tech().vhs.xhr.offResponse(playerResponseHook);
});

The global videojs.Vhs also exposes an xhr property. Adding onRequest and/or onResponse hooks will allow you to intercept the request options and xhr Object as well as request, error, and response data for all requests in every player on a page. For consistency across browsers the video source should be set at runtime once the video player is ready.

Example:

// Global request callback, will affect every player.
const globalRequestHook = (options) => {
  return {
    uri: 'https://new.options.global.uri'
  };
};
videojs.Vhs.xhr.onRequest(globalRequestHook);
// Global request callback defining beforeSend function, will affect every player.
const globalXhrRequestHook = (options) => {
  options.beforeSend = (xhr) => {
    xhr.setRequestHeader('foo', 'bar');
  };
  return options;
};
videojs.Vhs.xhr.onRequest(globalXhrRequestHook);
// Global response hook callback, will affect every player.
const globalResponseHook = (request, error, response) => {
  const bar = response.headers.foo
};

videojs.Vhs.xhr.onResponse(globalResponseHook);
// Remove a global onRequest callback.
videojs.Vhs.xhr.offRequest(globalRequestHook);
// Remove a global onResponse callback.
videojs.Vhs.xhr.offResponse(globalResponseHook);

For information on the type of options that you can modify see the documentation at https://github.com/Raynos/xhr.

vhs.stats

Type: object

This object contains a summary of HLS and player related stats.

Property Name Type Description
bandwidth number Rate of the last segment download in bits/second
mediaRequests number Total number of media segment requests
mediaRequestsAborted number Total number of aborted media segment requests
mediaRequestsTimedout number Total number of timedout media segment requests
mediaRequestsErrored number Total number of errored media segment requests
mediaTransferDuration number Total time spent downloading media segments in milliseconds
mediaBytesTransferred number Total number of content bytes downloaded
mediaSecondsLoaded number Total number of content seconds downloaded
buffered array List of time ranges of content that are in the SourceBuffer
currentTime number The current position of the player
currentSource object The source object. Has the structure {src: 'url', type: 'mimetype'}
currentTech string The name of the tech in use
duration number Duration of the video in seconds
main object The main playlist object
playerDimensions object Contains the width and height of the player
seekable array List of time ranges that the player can seek to
timestamp number Timestamp of when vhs.stats was accessed
videoPlaybackQuality object Media playback quality metrics as specified by the W3C's Media Playback Quality API

Events

Standard HTML video events are handled by video.js automatically and are triggered on the player object.

loadedmetadata

Fired after the first segment is downloaded for a playlist. This will not happen until playback if video.js's metadata setting is none

xhr-hooks-ready

Fired when the player xhr object is ready to set onRequest and onResponse hooks, as well as remove hooks with offRequest and offResponse.

VHS Usage Events

Usage tracking events are fired when we detect a certain HLS feature, encoding setting, or API is used. These can be helpful for analytics, and to pinpoint the cause of HLS errors. For instance, if errors are being fired in tandem with a usage event indicating that the player was playing an AES encrypted stream, then we have a possible avenue to explore when debugging the error.

Note that although these usage events are listed below, they may change at any time without a major version change.

VHS usage events are triggered on the tech with the exception of the 3 vhs-reload-error events, which are triggered on the player.

To listen for usage events triggered on the tech, listen for the event type of 'usage':

player.on('ready', () => {
  player.tech().on('usage', (e) => {
    console.log(e.name);
  });
});

Note that these events are triggered as soon as a case is encountered, and often only once. For example, the vhs-demuxed usage event will be triggered as soon as the main manifest is downloaded and parsed, and will not be triggered again.

Presence Stats

Each of the following usage events are fired once per source if (and when) detected:

Name Description
vhs-webvtt main manifest has at least one segmented WebVTT playlist
vhs-aes a playlist is AES encrypted
vhs-fmp4 a playlist used fMP4 segments
vhs-demuxed audio and video are demuxed by default
vhs-alternate-audio alternate audio available in the main manifest
vhs-playlist-cue-tags a playlist used cue tags (see useCueTags(#usecuetags) for details)
vhs-bandwidth-from-local-storage starting bandwidth was retrieved from local storage (see useBandwidthFromLocalStorage(#useBandwidthFromLocalStorage) for details)
vhs-throughput-from-local-storage starting throughput was retrieved from local storage (see useBandwidthFromLocalStorage(#useBandwidthFromLocalStorage) for details)

Use Stats

Each of the following usage events are fired per use:

Name Description
vhs-gap-skip player skipped a gap in the buffer
vhs-player-access player.vhs was accessed
vhs-audio-change a user selected an alternate audio stream
vhs-rendition-disabled a rendition was disabled
vhs-rendition-enabled a rendition was enabled
vhs-rendition-excluded a rendition was excluded
vhs-timestamp-offset a timestamp offset was set in HLS (can identify discontinuities)
vhs-unknown-waiting the player stopped for an unknown reason and we seeked to current time try to address it
vhs-live-resync playback fell off the back of a live playlist and we resynced to the live point
vhs-video-underflow we seeked to current time to address video underflow
vhs-error-reload-initialized the reloadSourceOnError plugin was initialized
vhs-error-reload the reloadSourceOnError plugin reloaded a source
vhs-error-reload-canceled an error occurred too soon after the last reload, so we didn't reload again (to prevent error loops)

In-Band Metadata

The HLS tech supports timed metadata embedded as ID3 tags. When a stream is encountered with embedded metadata, an in-band metadata text track will automatically be created and populated with cues as they are encountered in the stream. UTF-8 encoded TXXX and WXXX ID3 frames are mapped to cue points and their values set as the cue text. Cues are created for all other frame types and the data is attached to the generated cue:

cue.value.data

There are lots of guides and references to using text tracks around the web.

Segment Metadata

You can get metadata about the segments currently in the buffer by using the segment-metadata text track. You can get the metadata of the currently rendered segment by looking at the track's activeCues array. The metadata will be attached to the cue.value property and will have this structure

cue.value = {
  byteLength, // The size of the segment in bytes
  bandwidth, // The peak bitrate reported by the segment's playlist
  resolution, // The resolution reported by the segment's playlist
  codecs, // The codecs reported by the segment's playlist
  uri, // The Segment uri
  timeline, // Timeline of the segment for detecting discontinuities
  playlist, // The Playlist uri
  start, // Segment start time
  end // Segment end time
};

Example: Detect when a change in quality is rendered on screen

let tracks = player.textTracks();
let segmentMetadataTrack;

for (let i = 0; i < tracks.length; i++) {
  if (tracks[i].label === 'segment-metadata') {
    segmentMetadataTrack = tracks[i];
  }
}

let previousPlaylist;

if (segmentMetadataTrack) {
  segmentMetadataTrack.on('cuechange', function() {
    let activeCue = segmentMetadataTrack.activeCues[0];

    if (activeCue) {
      if (previousPlaylist !== activeCue.value.playlist) {
        console.log('Switched from rendition ' + previousPlaylist +
                    ' to rendition ' + activeCue.value.playlist);
      }
      previousPlaylist = activeCue.value.playlist;
    }
  });
}

Object as Source

Note that this is an advanced use-case, and may be more fragile for production environments, as the schema for a VHS object and how it's used internally are not set in stone and may change in future releases.

In normal use, VHS accepts a URL as the source of the video. But VHS also has the ability to accept a JSON object as the source.

Passing a JSON object as the source has many uses. A couple of examples include:

  • The manifest has already been downloaded, so there's no need to make another request
  • You want to change some aspect of the manifest, e.g., add a segment, without modifying the manifest itself

In order to pass a JSON object as the source, provide a parsed manifest object in via a data URI, and using the "vnd.videojs.vhs+json" media type when setting the source type. For instance:

var player = videojs('some-video-id');
const parser = new M3u8Parser();

parser.push(manifestString);
parser.end();

player.src({
  src: `data:application/vnd.videojs.vhs+json,${JSON.stringify(parser.manifest)}`,
  type: 'application/vnd.videojs.vhs+json'
});

The manifest object should follow the "VHS manifest object schema" (a somewhat flexible and informally documented structure) provided in the README of m3u8-parser and mpd-parser. This may be referred to in the project as vhs-json.

Hosting Considerations

Unlike a native HLS implementation, the HLS tech has to comply with the browser's security policies. That means that all the files that make up the stream must be served from the same domain as the page hosting the video player or from a server that has appropriate CORS headers configured. Easy instructions are available for popular webservers and most CDNs should have no trouble turning CORS on for your account.

Known Issues and Workarounds

Issues that are currenty known. If you want to help find a solution that would be appreciated!

Fragmented MP4 Support

Edge has native support for HLS but only in the MPEG2-TS container. If you attempt to play an HLS stream with fragmented MP4 segments (without overriding native playback), Edge will stall. Fragmented MP4s are only supported on browsers that have Media Source Extensions available.

Assets with an Audio-Only Rate Get Stuck in Audio-Only

Some assets which have an audio-only rate and the lowest-bandwidth audio + video rate isn't that low get stuck in audio-only mode. This is because the initial bandwidth calculation thinks it there's insufficient bandwidth for selecting the lowest-quality audio+video playlist, so it picks the only-audio one, which unfortunately locks it to being audio-only forever, preventing a switch to the audio+video playlist when it gets a better estimation of bandwidth.

Until we've implemented a full fix, it is recommended to set the enableLowInitialPlaylist option for any assets that include an audio-only rate; it should always select the lowest-bandwidth audio+video playlist for its first playlist.

It's also worth mentioning that Apple no longer requires having an audio-only rate; instead, they require a 192kbps audio+video rate (see Apple's current HLS Authoring Specification). Removing the audio-only rate would of course eliminate this problem since there would be only audio+video playlists to choose from.

Follow progress on this in issue #175.

DASH Assets with $Time Interpolation and SegmentTimelines with No t

DASH assets which use $Time in a SegmentTemplate, and also have a SegmentTimeline where only the first S has a t and the rest only have a d, do not load currently.

There is currently no workaround for this, but you can track progress on this in issue #256.

Testing

For testing, you run npm run test. You will need Chrome and Firefox for running the tests.

videojs-http-streaming uses BrowserStack for compatibility testing.

Debugging

videojs-http-streaming makes use of videojs.log for debug logging. You can enable these logs by setting the log level to debug using videojs.log.level('debug'). You can access a complete history of the logs using videojs.log.history(). This history is maintained even when the log level is not set to debug.

vhs.stats can also be helpful when debugging. Accessing this object will give you a snapshot summary of various HLS and player stats. See vhs.stats for details about what this object contains.

NOTE: The debug level is only available in video.js v6.6.0+. With earlier versions of video.js, no debug messages will be logged to console.

Release History

Check out the changelog for a summary of each release.

Building

To build a copy of videojs-http-streaming run the following commands

git clone https://github.com/videojs/http-streaming
cd http-streaming
npm i
npm run build

videojs-http-streaming will have created all of the files for using it in a dist folder

Development

Tools

Commands

All commands for development are listed in the package.json file and are run using

npm run <command>

http-streaming's People

Contributors

adrums86 avatar alex-barstow avatar bc-bbay avatar bcdmlap avatar bclwhitaker avatar benjaminp avatar brandonocasey avatar dmlap avatar dzianis-dashkevich avatar essk avatar evanfarina avatar forbesjo avatar gesinger avatar gkatsev avatar greenkeeper[bot] avatar harisha-swaminathan avatar heff avatar imbcmdth avatar ldayananda avatar mikrohard avatar mister-ben avatar misteroneill avatar mjneil avatar paruls avatar rajkosto avatar squarebracket avatar tom-johnson avatar tomjohnson916 avatar wseymour15 avatar zhuangs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

http-streaming's Issues

add coveralls for coverage tracking

Sync up with video.js's build processes, use coveralls for code coverage, add a badge showing the coverage and perhaps add a PR hook indicating coverage percentage change.

What are the differences to videojs-contrib-hls?

Hi, I seriously appreciate your work and I am totally overwhelmed that there are now two hls projects in the videojs org, but it also would be really great if you would like to explain (maybe in a blog post) the reasoning behind those two repos - why does this repo exist and how does it relate to videojs-contrib-hls?

As a casual user I find the current situation very confusing. Which codebase to follow?

Thank you very much!

How to encrypt the m3u8 video, ask key to encrypt the encrypted string, and how to decrypt the player

Description

In dealing with m3u8 encrypted video, when requesting key, return the corresponding key string.Videojs-contrib-hls to get the string for ArrayBuffer processing, and I can't find the source code matching in the source code. The current scenario is that the key interface obtains an encrypted key string through the algorithm defined by the front and back ends, but this string is not plaintext. After videojs-contrib-hls gets it, it cannot match. I need to modify the source code and unlock the encrypted key. Identify the videojs-contrib-hls. How can I do it, please? How to modify the source code?

webpack import videojs-contrib-hls will not register hls source handler for html5 tech, that cause media_err_src_not_supported

Description

  1. When i use webpack to bundle videojs and contrib-hls, the video-contrib-hls will not register sourceHandlers of "Html5" tech. So, if i try to play m3u8 video in chrome, the console will printed out:
    "
    VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) No compatible source was found for this media
    "
  2. If i use videojs and videojs-contrib-hls with a tag in html, the contrib-hls will register sourceHandlers of "Html5" tech right. Everything works fine.

Sources

`_Tech.selectSourceHandler = function (source, options) {
var handlers = _Tech.sourceHandlers || [];
var can = void 0;

for (var i = 0; i < handlers.length; i++) {
  can = handlers[i].canHandleSource(source, options);

  if (can) {
    return handlers[i];
  }
}`

in above code of video.js, i found there is only ONE default sourceHandlers for “html5” tech, no HLS source handler registered. If i use webpack manner:
import 'video.js/dist/video-js.css' import videojs from 'video.js' window.videojs = videojs // hls plugin for videojs6 require('videojs-contrib-hls/dist/videojs-contrib-hls.js')
but if i use normal cdn script tag manner, everything works fine, and there are TWO source handler, one of which is the HLS source handler.

Steps to reproduce

Explain in detail the exact steps necessary to reproduce the issue.

  1. use webpack bundle including video.js and video.contrib-hls
  2. play a m3p8 using video.js

Results

There will be following error in console:
'
VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) No compatible source was found for this media
'

Expected

Works well , it should be the same as in CDN script tag manner.

Error output

VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) No compatible source was found for this media

Additional Information

Please include any additional information necessary here. Including the following:

videojs-contrib-hls version

what version of videojs-contrib-hls does this occur with?
videojs-contrib-hls 5.14.1

videojs version

what version of videojs does this occur with?
video.js 6.7.3

Browsers

what browsers are affected? please include browser and version for each
chrome 63.0.3239.132 , firefox not work
Edge works well

Platforms

what platforms are affected? please include operating system and version or device and version for each
I am testing in windows 10 64 bit

Broken design

This morning I noticed that the videos on my site were all broken, as if a css file had not loaded. I then looked online and saw https://videojs.github.io/http-streaming/ also had the same problem I'm having.

I also saw VideoJS updated to version 7 - could this be the source of the problem?

screen shot 2018-05-20 at 09 49 44

What could I do to go around this problem?

Thanks,
Diego

CueStart and CueDuration does not sync up with the Cue Out and Duration time with m3u8 file

Description

I have been able to get the textTracks using a modified program. I am expecting my Cue to load at 48 secs for 12 secs and then at 78 secs for 20 secs. I am instead getting VTT Cues at 40 secs for 40 secs duration. I am not sure how this cue start and duration are picked up from.## Sources
Is a certain source or a certain segment affected? please provide a public (accesible over the internet) link to it below.

I am including the link to my code, logs and the m3u8 file.
https://gist.github.com/varadarajana/9c0cd051b646a4f70a869a65143305be

Steps to reproduce

  1. Just by playing the Demoplayer with names Video fragments as specified in m3h8 file we will be able to reproduce this issue.

If only `#EXT-X-ENDLIST` is added to a playlist, the update isn't seen

Description

I saw an issue where intermittently it would not recognize that a live stream had ended, it would stall on the last frame and show the loading indicator, but not progress further. In the console you would see multiple instances of this message, and it would keep re-requesting the m3u8 file periodically.

video.js:498 VIDEOJS: WARN: Problem encountered with the current HLS playlist. Trying again since it is the final playlist.
video.js:498 VIDEOJS: WARN: Problem encountered with the current HLS playlist. Trying again since it is the final playlist.
video.js:498 VIDEOJS: WARN: Problem encountered with the current HLS playlist. Trying again since it is the final playlist.

Sources

Sorry, I don't have a public source to share.

Steps to reproduce

Explain in detail the exact steps necessary to reproduce the issue.

This is a test that only updates the endList property when calling updateMaster. On the current head of master it will fail.

  1. Add this test to tests/playlist-loader.test.js
QUnit.test('updateMaster updates master when endList changes', function(assert) {
  const playlist = {
    endList: false,
    mediaSequence: 0,
    attributes: {
      BANDWIDTH: 9
    },
    uri: 'playlist-0-uri',
    resolvedUri: urlTo('playlist-0-uri'),
    segments: [{
      duration: 10,
      uri: 'segment-0-uri',
      resolvedUri: urlTo('segment-0-uri')
    }]
  };

  const master = {
    playlists: [playlist]
  };

  const media = Object.assign({}, playlist, {
    endList: true
  });

  assert.deepEqual(
    updateMaster(master, media),
    {
      playlists: [{
        endList: true,
        mediaSequence: 0,
        attributes: {
          BANDWIDTH: 9
        },
        uri: 'playlist-0-uri',
        resolvedUri: urlTo('playlist-0-uri'),
        segments: [{
          duration: 10,
          uri: 'segment-0-uri',
          resolvedUri: urlTo('segment-0-uri')
        }]
      }]
    },
    'updates master when endList changes');
});
  1. Run tests

Results

Expected

Playlist should update when endList changes

Error output

You will see this message repeated in the console when this happens

video.js:498 VIDEOJS: WARN: Problem encountered with the current HLS playlist. Trying again since it is the final playlist.

Additional Information

Please include any additional information necessary here. Including the following:

videojs-contrib-hls version

what version of videojs-contrib-hls does this occur with?
videojs-contrib-hls x.y.z

videojs version

what version of videojs does this occur with?
video.js 5.14.1
video.js 7.0.0 as well (still in https://github.com/videojs/http-streaming/blob/master/src/playlist-loader.js#L97)

Browsers

what browsers are affected? please include browser and version for each
All

Platforms

what platforms are affected? please include operating system and version or device and version for each
All

Other Plugins

are any other videojs plugins being used on the page? If so, please list them with version below.
No

Other JavaScript

are you using any other javascript libraries or frameworks on the page? if so please list them below.
No

Audio only toggle (disable video but continue playing the audio stream)

Description

Is there a way to programatically disable the video stream while continuing to play the selected audio stream for HLS streams?

Results

Expected

Clicking on a audio only toggle would allow me to disable the video stream (maybe replace with an image) but allow the audio to continue running to save bandwidth while driving

videojs-contrib-hls version

what version of videojs-contrib-hls does this occur with?
videojs-contrib-hls 5.14.0

videojs version

what version of videojs does this occur with?
video.js 5.6.0

Problem with Android Chrome

Description

I hava a file video.m3u8 which contained some .ts file url, and I save the video.m3u8 as video without file name extension.

I used this code <source src="/video/video" type="application/x-mpegURL"> to play HLS video,
It worked successfully on Chorme desktop, but not on Android Chrome.

When I turned video back to video.m3u8 and add .m3u8 to source tag's src like <source src="/video/video.m3u8" type="application/x-mpegURL">, it worked fine on both desktop and Android Chrome.

In order to find what went wrong, I used Google Chrome Remote Debug to remote observe on Android Chrome console. There is no error log. Does anyone knows why?

Sources

Is a certain source or a certain segment affected? please provide a public (accesible over the internet) link to it below.

<!DOCTYPE html>
<html>
   <head>
      <meta charset="utf-8">
      <title>Test</title>
      <link href="http://vjs.zencdn.net/6.2.8/video-js.css" rel="stylesheet">
   </head>
   <body>
      <video id="player" class="video-js vjs-default-skin" controls preload>
         <!-- <source src="/video/video.m3u8" type="application/x-mpegURL"> -->
         <source src="/video/video" type="application/x-mpegURL">
      </video>
      <script src="http://vjs.zencdn.net/6.2.8/video.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/videojs-contrib-hls/5.12.2/videojs-contrib-hls.min.js"></script>
      <script>
          var player = videojs('player');
          player.play();
     </script>
   </body>
</html>

videojs-contrib-hls version

what version of videojs-contrib-hls does this occur with?
videojs-contrib-hls 5.12.2

videojs version

what version of videojs does this occur with?
video.js 6.2.8

Browsers

what browsers are affected? please include browser and version for each

  • Android Chrome 62.0.3202.84 (not working)
  • Mac Chrome 62.0.3202.94 (working)

Platforms

what platforms are affected? please include operating system and version or device and version for each

  • Android 7.0
  • Mac 10.12.6

Other Plugins

are any other videojs plugins being used on the page? If so, please list them with version below.
*

Other JavaScript

are you using any other javascript libraries or frameworks on the page? if so please list them below.
*

Trigger tech event when master playlist failed to load

Hi there, I'm wondering if we could add a line like

this.tech_.trigger('nomasterplaylist');

somewhere around https://github.com/videojs/videojs-contrib-hls/blob/master/src/master-playlist-controller.js#L864

Because this is a pretty frequent case with broken CORS headers, but all I can rely on is the tech.trigger('error', hlserror), so I have to set a handler on the very generic 'error' event and then filter out by "HLS" being in the error message which is not.. ideal..

What do you think?

cc @robinmaben

Some m3u8 videos are stuck when played repeatedly after the first time

Description

I find my m3u8 videos are stuck when played repeatedly, but they play normal for the first time!
I tried playing video with safari and firefox, but did not discover this problem. Only have problems in chrome!
I tried playing video on ipone7's safari with native video tag,but did not discover this problem.

Sources

experiment URL : http://videojs.github.io/videojs-contrib-hls/
experiment source: http://n1-q.mafengwo.net/s11/M00/D4/FE/wKgBEFrQXCmAOPHmAAAB4fZtONI06.m3u8

Browsers

chrome 65.0.3325.181

Not able to intercept/modify the index.m3u8 file requests in Safari

Description

I'm trying to intercept/modify the index.m3u8 file requests, for some application-specific purpose, using one of the following possible methods:

  • update the 'resolveUrl' method inside videojs-contrib-hls.js, to modify the target url for index.m3u8
  • use the 'player.hls.xhr.beforeRequest' callback(specific to videojs-contrib-hls) or the 'videojs.Hls.xhr.beforeRequest' callback(specific to videojs)

Any of the above method is NOT working in case of Mac Safari. The code flow won't even hit any of the above methods. I'm guessing it's because, I'm not able to override the native hls behaviour on Safari, even after using the required 'overrideNative' parameter.

videojs.options.hls.overrideNative = true;
videojs.options.html5.nativeAudioTracks = false;
videojs.options.html5.nativeVideoTracks = false;

Is there any other way to intercept the index.m3u8 calls and/or force the contrib-hls behaviour over the native hls behaviour?

videojs-contrib-hls version

videojs-contrib-hls 5.12.2

videojs version

video.js 6.7.3

Browsers

  • Safari 11.0.3

Platforms

  • MacOS 10.13.3

Momentary loss of connection makes player stop working with encrypted hls

Description

I've already discussed about this issue on videojs/videojs-contrib-hls#1030 and at the time we agreed to fix this using blacklists. However, when using an encrypted hls stream the problem still remains.
After some debugging I found out that it might be happening when the connection breaks while downloading the encryption key.
The behavior for retrying a new segment is bound to the progress event, however, this event is bound just to the segmentXhr request and not to the keyXhr request.

One way that I found that could fix it is to bind this event to the key request as well.

See media-segment-request.js

const keyRequestCallback = handleKeyResponse(segment, finishProcessingFn);
const keyXhr = xhr(keyRequestOptions, keyRequestCallback);
//Probable solution
keyXhr.addEventListener('progress', handleProgress(segment, progressFn));
activeXhrs.push(keyXhr); 

Since I don't know the code this well I'm not confident to say that this would be the right solution for the problem.

Could anybody help?

Sources

Use this m3u8 file:
https://s3.amazonaws.com/player.hotmart.dev/video/lYq2j96qaG/hls/master.m3u8

Steps to reproduce

  1. Go to videjs hls demo page and click play
  2. After some time (like 5 seconds), go to chromes developer tools, network and make it offline.
  3. When it try to load new segments you'll be able to see some warnings on the console and that it keeps trying to download new segments from time to time. When the connection returns (toggle offline off) it will start playing again.
  4. Repeat the steps above using the source url informed. A connection error will be thrown but it won't retry to download segments anymore. Even when the connection returns nothing will happen

videojs-contrib-hls version

videojs-contrib-hls 5.14.1 (Using the demo page)

videojs version

what version of videojs does this occur with?
video.js 6.7.3 (Using the demo page)

Browsers

Tested on chrome but I'm pretty sure it happens on all browsers

Uncaught exception at 'addSourceBuffer' when changing source or disposing/re-creating video

Description

In our scenario, we need to dynamically create a video, change its source several times within few seconds (user will be previewing videos), and dispose and re-create it at some point.

Using our video source files, when in the middle of a video, we change the video source through videojs().src function, an Uncaught DOMException: Failed to execute 'addSourceBuffer' on 'MediaSource': This MediaSource has reached the limit of SourceBuffer objects it can handle. is received.

Here is a reduced test case on jsbin:
http://jsbin.com/tojewagula/edit?html,console,output

Here are the source files you can download and check (npm install and npm start should be enough):
https://drive.google.com/file/d/0B-Ny3L4qtHdUXzRaZlltWjF0YXM/view?usp=sharing

Here are some example M3U8 URLs we are using:
https://scdn.golden-race.net/hlsvideos/dog6/d6-5-4-3-1437.m3u8?st=JMUY2EVWtAHdK-GDFcNyMw&e=1485420418
https://scdn.golden-race.net/hlsvideos/sp/s4-4-3-054.m3u8?st=BvMPTBAMEamHQICmFvEoJg&e=1485424078
https://scdn.golden-race.net/hlsvideos/mt/mt-5-4-1-0229.m3u8?st=yYu5J6ml4wkTdgSrbAkY9Q&e=1485424498

Sources

We realized that inserting a debug point in the function createRealSourceBuffers_() provoked that this exception is never thrown, so we just inserted a simple wait of just before the buffer is created with _this2.mediaSource_.nativeMediaSource_.addSourceBuffer(...), and it's working almost all the times (we still get the exception sometimes on extreme conditions).

Steps to reproduce

Using the given jsbin example:

  1. Choose one of our URLs, paste it in the text input, and press Load. In the browser console you can check that the video is created with the given url and it starts playing.
  2. After waiting a couple of seconds, press Load again with the same video or choose a different one (may have to do that several times until the error is found).
  3. Encounter the error.

Note: Can be also discovered even though video is disposed.

Results

Expected

Video should be working correctly, even though is Loaded several times and/or disposed.

Error output

An unexpected error is found and video looses sound.

Additional Information

We were're NOT able to reproduce this issue with a couple of example videos found on the internet ( e.g. https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8 ), but trying to figure out what were the differences between both videos, we found that they're almost the same: same enconding, videos with different resolutions and several audio streams... It's driving us crazy!

videojs-contrib-hls version

videojs-contrib-hls 4.1.0

videojs version

video.js 5.15.1

Browsers

All

Platforms

All

Other Plugins

No other plugins are being used.

Other JavaScript

jQuery 1.8.0

How to catch segment/playlist errors

Description

Most of our streams come from local small business DVRs and aren't very reliable. I've tried using the hls-timestamp-offset event for error recovery with limited success. Is there a way to catch segment or playlist errors? If not, would it be possible for you to add an event or the ability to specify an error function to videojs.Hls.xhr?

Sources

Sorry, my sources are private.

Steps to reproduce

Explain in detail the exact steps necessary to reproduce the issue.

  1. Load a video stream from an unstable source.
  2. Wait for it to error.

Results

Expected

The player continues to try and load the stream.

Error output

If there are any errors in the console, from the player, or anywhere else please include them here:

Additional Information

Please include any additional information necessary here. Including the following:

videojs-contrib-hls version

what version of videojs-contrib-hls does this occur with?
5.14.1

videojs version

what version of videojs does this occur with?
6.8.0

Browsers

what browsers are affected? please include browser and version for each

  • Waterfox 56.0.4.1
  • Chrome 65.0.3325.181

Platforms

what platforms are affected? please include operating system and version or device and version for each

  • Windows 7
  • Windows 10

Other Plugins

are any other videojs plugins being used on the page? If so, please list them with version below.

  • videojs-errors 3.1.0

Other JavaScript

are you using any other javascript libraries or frameworks on the page? if so please list them below.

  • jQuery 3.3.1
  • Angular 1.6.2

Demo with Firefox: Specified “type” attribute of “application/x-mpegURL” is not supported.

I do not want to annoy you, so sorry for posting this here besides the one in the other repo - but I do not understand why the demo page gives me that console output:

Specified “type” attribute of “application/x-mpegURL” is not supported. Load of media resource //d2zihajmogu5jn.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8 failed. All candidate resources failed to load. Media load paused. All candidate resources failed to load. Media load paused.
This is with Firefox 59 on Ubuntu. i have seen this error on OSX, too.

Ah, yes, sorry, i should add that the video plays, but the console message is annoying. Also I just do not understand why that happens I would like to learn about that. Thanks!

m3u8 in mobile cannot requestAnimationFrame?

Hi,

I am creating a video stream app, i am using drawImage() to copy from video to canvas, it is well working in PC, but when i am testing it on my phone it seems drawImage is not working. is m3u8 have restriction over it? or i did wrong?

Thanks

this is my working phone, hope you can answer my questions

`function HLSFunc(a,b,c){
if (document.getElementById('ng-player') == null ){
var videojsContainer = document.createElement('video-js');
videojsContainer.id = "ng-player";
document.getElementById('ng-container').appendChild(videojsContainer);
document.getElementById('ng-player').setAttribute('width','100')
document.getElementById('ng-player').setAttribute('height','100')
document.getElementById('ng-player').setAttribute('controls',true)
document.getElementById('ng-player').setAttribute('playsinline',true);
}
player = videojs('ng-player');
var url = 'https://d2zihajmogu5jn.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8'
var mimetype = 'application/x-mpegURL';

        videojs.Hls.xhr.beforeRequest = function(options) {
          drawToCanvas();
          return options;
        };

        player.ready(function() {
          this.src({
            src: url,
            type: mimetype
          });
        });
      }

      function drawToCanvas(){

        var video = $('#ng-player_html5_api')[0];
        var inputCtx = $('#canvas')[0].getContext('2d');

        inputCtx.drawImage(video,0,0,420,320);
        window.requestAnimationFrame(drawToCanvas);
      }`

"Media could not be loaded"

Hi all, quick question that my lack of experience may be the cause of the problem.

Sometimes I get a "Media could not be loaded" error, which is weird because as soon as it is reloaded it works fine.

screen shot 2018-06-08 at 11 39 14

How can I catch this error and reload programmatically?

Prevent downloading encrypted content with Firefox video download helper extension

Hi All,

We have spent quite a bit of time trying to provide the best possible security by encoding our media through AWS with AES 128 bit encryption this has worked great for a long time but like everything on the web we have been shown that this can be easily downloaded using the following plugin.

https://addons.mozilla.org/en-GB/firefox/addon/video-downloadhelper/

Simply install the extension in Firefox and then install the companion app and click download and covert

We have set up an example below.
http://output.jsbin.com/fabefit/1/

Can anyone suggest any way to prevent this I totally understand that its pretty much impossible to prevent videos from being stolen simply using screengrab software will do the job and nothing can prevent this but it would be good to prevent simple downloads from extensions make it as hard as possible?

We recently viewed a post here: videojs/videojs-contrib-hls#1337 about possibly obfuscating the requests.

Maybe we are missing a step that can prevent this any info would be appreciated?

Thanks

Seek to last playlist mediaIndex

Description

The player starts playing a playlist with 0 index, but it is quickly deleted by the server. How can I start playing from the last playlist index?

In my case, you need to play with odminn23_1-408.ts, but playing with odminn23_1-404.ts

generateSegmentInfo_(){
    ...
    playlist.segments[mediaIndex]; //current 0, need 4
    ...
}

Sources

The playlist:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:404
#EXT-X-TARGETDURATION:13
#EXTINF:12.500,
odminn23_1-404.ts
#EXTINF:12.500,
odminn23_1-405.ts
#EXTINF:12.500,
odminn23_1-406.ts
#EXTINF:12.500,
odminn23_1-407.ts
#EXTINF:12.500,
odminn23_1-408.ts

Connection Refused errors are handled poorly

Description

If the media server goes down while a stream is playing, the screen will freeze when the buffer runs out, but no buffering spinner will be displayed. In the case of a live stream, contrib-hls will keep trying to download the playlist. In the case of a VOD stream, it will keep trying to download the last TS file.

Sources

Should work with any source?

Steps to reproduce

Explain in detail the exact steps necessary to reproduce the issue.

  1. Start playing an HLS stream.
  2. Bring down the server that's serving the media.
  3. Watch the result.

Results

Expected

Buffering animation occurs immediately after the buffer is exhausted. Additionally, maybe an error should be thrown after a configurable amount of time stalled with no download progress or a number of failed XHRs.

Error output

A constant output of net::ERR_CONNECTION_REFUSED and the warning:
VIDEOJS: WARN: Problem encountered with the current HLS playlist. Trying again since it is the final playlist.

Additional Information

videojs-contrib-hls version

videojs-contrib-hls 5.12.2

videojs version

video.js 6.4.0

Browsers/Platforms

  • Linux/Chrome 62
  • macOS/Chrome 62
  • macOS/Safari 11.0.1
  • Windows/Chrome 62
  • Windows/IE11

Other JavaScript

Just using the hosted test player at http://videojs.github.io/videojs-contrib-hls/

CODE:3 MEDIA_ERR_DECODE on Mac Safari

Hello there,

I'm using VideoJS and videojs-contrib-hls without setting overrideNative to true on Mac Safari with a streaming URL of a live broadcast.

I got the following error:

[Error] VIDEOJS: (4)
“ERROR:”
“(CODE:3 MEDIA_ERR_DECODE)”
“The media playback was aborted due to a corruption problem or because the media used features your browser did not support.”
MediaError {code: 3, message: “The media playback was aborted due to a corruption…media used features your browser did not support.“, status: null, MEDIA_ERR_CUSTOM: 0, MEDIA_ERR_ABORTED: 1, …}
    logByType (video.js:498)
    error (video.js:620)
    error (video.js:23829)
    handleTechError_ (video.js:22449)
    bound (video.js:2348)
    bound (video.js:2348)
    dispatcher (video.js:1971)

Surprisingly, the error disappeared and the video continued playing after a while.

Any thoughts?
What does this error refer to? Is there a problem with the streaming URL?

videojs-contrib-hls version

5.13.0

videojs version

6.7.4

Browsers

Safari

Platforms

macOS

Thanks.

cause of Cannot read property 'segments' of undefined

Description

Briefly describe the issue.
some m3u8 can not play and console print "Cannot read property 'segments' of undefined "
if your PAT of ts have NIT ,it will cause videojs-contrib-hls analysis PMT failed。

Sources

15102: parseType(data.subarray(i + 4, i + 8));

Steps to reproduce

Explain in detail the exact steps necessary to reproduce the issue.
Sample PAT :
47 40 00 14 00 00 B0 11 00 00 C1 00 00 00 00 E0 1F 00 01 E1 00 23 5A AB 82
| NIT | PMT | CRC |

Results

Expected

console print :Cannot read property 'segments' of undefined

Error output

If there are any errors in the console, from the player, or anywhere else please include them here:

Additional Information

Please include any additional information necessary here. Including the following:

videojs-contrib-hls version

what version of videojs-contrib-hls does this occur with?

videojs version

what version of videojs does this occur with?
Video.js 6.4.0

Browsers

what browsers are affected? please include browser and version for each
*
chorme

Platforms

what platforms are affected? please include operating system and version or device and version for each
*

Other Plugins

are any other videojs plugins being used on the page? If so, please list them with version below.
*

Other JavaScript

are you using any other javascript libraries or frameworks on the page? if so please list them below.
*

Support alternative video tracks [RFC8216 (Section 4.3.4.2.1)]

Description

Sources

I do not have a webhost I could use to the demo files I am currently using. The demo I am using with just 4 camera angles (will be 9 soon) already takes up 1.46 GB.

I might create a very simple test I could host on GitHub Pages if needed.

Copied below is my test files: (Independent testing via VLC and MPV show that the video tracks appear and can be switched to.)

test.html

<head>
  <link href="http://vjs.zencdn.net/6.4.0/video-js.css" rel="stylesheet">

  <!-- IE8 Support -->
  <script src="http://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"></script>

  <script src="http://vjs.zencdn.net/6.4.0/video.js"></script>
  <script src="https://unpkg.com/videojs-flash/dist/videojs-flash.js"></script>
  <script src="https://unpkg.com/videojs-contrib-hls/dist/videojs-contrib-hls.js"></script>
  <script>
    var player = videojs('my-video');
    player.play();
  </script>
</head>

<body>
  <video id="my-video" class="video-js" controls preload="auto" width="1280" height="720" data-setup="{}">
    <source src="multicam.m3u8" type='application/x-mpegURL'>
    <p class="vjs-no-js">
      To view this video please enable JavaScript, and consider upgrading to a web browser that
      <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
    </p>
  </video>
</body>

multicam.m3u8

#EXTM3U
#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="main",NAME="Auto Cam", DEFAULT=YES,URI="auto-cam/index.m3u8"
#EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="main",NAME="Director", DEFAULT=NO,URI="director/index.m3u8"

#EXT-X-STREAM-INF:BANDWIDTH=12163000,CODECS="mp4a.40.2,avc1.4d401e",VIDEO="main"
auto-cam/index.m3u8

auto-cam/index.m3u8 (First 10 segments of many).

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:13
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:11.973222,
auto-cam-000.ts
#EXTINF:8.450000,
auto-cam-001.ts
#EXTINF:12.500000,
auto-cam-002.ts
#EXTINF:8.333333,
auto-cam-003.ts
#EXTINF:12.500000,
auto-cam-004.ts
#EXTINF:8.333333,
auto-cam-005.ts
#EXTINF:8.333333,
auto-cam-006.ts
#EXTINF:12.500000,
auto-cam-007.ts
#EXTINF:7.266667,
auto-cam-008.ts
#EXTINF:12.500000,
auto-cam-009.ts
#EXTINF:11.300000,
auto-cam-010.ts

director/index.m3u8 is formated the same as auto-cam/index.m3u8.

Steps to reproduce

Explain in detail the exact steps necessary to reproduce the issue.

  1. Create a m3u8 playlist with alternative video tracks
  2. Play using video.js with video-contrib-hls.js

Results

Expected

I should be able to see and select the video tracks and audio tracks on screen.

Error output

None

Additional Information

videojs-contrib-hls version

  • videojs-contrib-hls 5.12.0

videojs version

  • video.js 6.4.0

Browsers

Tested on:

  • Chrome (63.0.3239.84)
  • Firefox (58.0b10)
  • Edge (Latest)
  • iOS Safari (11.2)

Seems to be all browsers.

Platforms

  • Tested on Windows and iOS

Other Plugins

  • videojs-ie8
  • videojs-flash

Cannot read property 'segments' of undefined

Description

Similar with this issue,some m3u8 source cannot play and throw an error,but it work in VLC and mobile browser.

Sources

I download a little part of source and make a test demo, please check the attachment
hls.zip

Expected

Confirm why the source cannot play,is it unspported by this plugin,or lack of something necessary?

Error output

Uncaught TypeError: Cannot read property 'segments' of undefined

videojs-contrib-hls version

videojs-contrib-hls 5.10.1

videojs version

video.js 6.2.5

Browsers

*Chrome 59.0.3071.115

Platforms

*Windows 10

Playback Error in Microsoft Edge. Media playback was aborted due to a corruption....

Description

Briefly describe the issue.

I'm getting a error message, only in Microsoft Edge, that states.

The media playback was aborted due to a corruption problem or because the media used features your browser did not support.

This message only seems to appear when a new segment is trying to be loaded. So it takes about 2 1/2 - 3 minutes before it will appear. I'm running Edge v16 which according to the support chart supports mp4 fragments.

Here is an example. It does the same thing in JSBin. Once again note this only happens in Microsoft Edge.
http://jsbin.com/natudaw/1/edit?html,output

Sources

This happens with all the videos in Edge. I don't see this issue at all in any of the other browsers except IE 11 which obviously doesn't support HLS.

Steps to reproduce

Explain in detail the exact steps necessary to reproduce the issue.

  1. Navigate to Sample
  2. Play Video
  3. Wait 3 minutes max

Results

Expected

The video to continue to play without error

Error output

The media playback was aborted due to a corruption problem or because the media used features your browser did not support.

videojs-contrib-hls version

what version of videojs-contrib-hls does this occur with?
videojs-contrib-hls v5.14.0

videojs version

what version of videojs does this occur with?
video.js 6.6.3

Browsers

what browsers are affected? please include browser and version for each
*Microsoft Edge

Platforms

what platforms are affected? please include operating system and version or device and version for each
*Windows 10

Other Plugins

are any other videojs plugins being used on the page? If so, please list them with version below.

  • No

Other JavaScript

are you using any other javascript libraries or frameworks on the page? if so please list them below.

  • Yes, but it is irrelevant since the same issue shows up in the JSBin sample.

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Replaced the old Node.js version in your .nvmrc with the new one

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

While doing HLS AES 128 playback, the player request key file for every chunk.

Description

I have the same question as this post:
videojs/videojs-contrib-hls#776

I want to control the key file request by php server script that only the valid user can get the AES key file. so I can not set cache expires of the key file.Therefor the php server been to very hevy. I had tried to modify mediaSegmentRequest function for check key.resovledUri and store the key value,but failed.
Is there any other way to fixed the proplem?
Thanks a lot!

videojs-contrib-hls version

videojs-contrib-hls 5.5.3

videojs version

video.js 5.19

Seeking to a time just before a segment finishes causes buffer underrun

Description

When seeking to a time just before the end of a segment, that segment will be downloaded, and playback will start. of course, once the seek to the end of the segment happens, the buffer is exhuasted, and thus you get a playback stall while it buffers up the next segment.

Sources

I've only really tested on streams with 6s segments. I'm not sure if the buffering is time-based; if the segments are smaller, it's possible enough would be buffered before playback.

Steps to reproduce

Explain in detail the exact steps necessary to reproduce the issue.

All you need to do is seek to just before a segment end that isn't buffered.

Results

Expected

The player buffers the following segment before starting playback

Error output

Additional Information

videojs-contrib-hls version

videojs-contrib-hls 5.10.0

videojs version

video.js 6.2.6

Browsers

All?

Platforms

All?

Other Plugins

  • videojs-contrib-dash
  • videojs-contrib-eme
  • videojs-contrib-quality-levels
  • videojs-airplay

Other JavaScript

are you using any other javascript libraries or frameworks on the page? if so please list them below.

  • bootstrap
  • jquery
  • some custom-written javascript for hotkey binding

Support highbitrate/4K content on MSE browsers like Firefox

Description

Unable to play HLS stream while segment size > 20MB

Sources

Any m3u8 playlist with fi (usally 1080p streams)

Steps to reproduce

Explain in detail the exact steps necessary to reproduce the issue.

  1. Navigate to demo player
  2. Play the video source

Results

Expected

Video can be played

Error output

VIDEOJS: ERROR: (CODE:-3 undefined) The quota has been exceeded.
Object { code: -3, type: "APPEND_BUFFER_ERR", message: "The quota has been exceeded.", originalError: DOMException }
video.js:129:5

videojs-contrib-hls version

latest

videojs version

latest

Browsers

Firefox

Request to allow promises for Hls.xhr.beforeRequest

Description

I am requesting for beforeRequest to allow promises to be used within the function. The reason why I am requesting this functionality is because I am using service call to update the uri value.
I need to update the uri this way because I am using NGINX’s secure_link module along with WOWZA. The secure link module requires all paths to be hashed by the client for authorization to view the video. I am using a service to generate the hash which is where my issue stems from.
I have tried using fetch api to make my requests, but beforeRequest continues to update the uri with the Promised fetch request that has not yet been fulfilled. Making the fetch call synchronous via async/await also has the same issue.
The solution to resolve this issue was by making a synchronous XMLHttpRequest for my request, but this is a short term solution because XMLHttpRequest is being deprecated.
I would like to help with this effort if possible, but I am unsure of where to start.

Sources

Is a certain source or a certain segment affected? please provide a public (accesible over the internet) link to it below.

Steps to reproduce

Explain in detail the exact steps necessary to reproduce the issue.

Override the function Hls.xhr.beforeRequest. Set the options.uri equal to a value that is fetched from a service.
Example:

window[`videojs`].Hls.xhr.beforeRequest =  function (options) {        
                                  
                //set the uri to a value that is retrieved from a service
                //fetchRequest makes a service call via fetch that returns a full uri
                options.uri = fetchRequest(path);
                
                return options;
            }

Results

Options updates in videojs before the promise is fulfilled causing the uri to be null.

Expected

Please describe what you expected to happen that did not happen in the description.
Videojs should update the uri after the promise is fulfilled

Error output

If there are any errors in the console, from the player, or anywhere else please include them here:

Additional Information

Please include any additional information necessary here. Including the following:

videojs-contrib-hls version

what version of videojs-contrib-hls does this occur with?
videojs-contrib-hls 5.12.2

videojs version

what version of videojs does this occur with?
video.js 6.6.3

Browsers

what browsers are affected? please include browser and version for each
*Google Chrome: Version 64.0.3282.186

Platforms

what platforms are affected? please include operating system and version or device and version for each
*

Other Plugins

are any other videojs plugins being used on the page? If so, please list them with version below.
*

Other JavaScript

are you using any other javascript libraries or frameworks on the page? if so please list them below.
*fetch

Start project

Tasks

  • get videojs-contrib-hls in a good state
  • push videojs-contrib-hls to vhs master
  • indicate in changelog that this is videojs-contrib-hls version x.y.z
  • update README
  • reset version to 0.1.0
  • publish to npm under @videojs/http-streaming
  • begin new work

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.