T
T
ttm2020-03-19 12:41:08
JavaScript
ttm, 2020-03-19 12:41:08

Video.js How to use http-streaming without manifest master?

I don't have one url with the master manifest, there are 3 separate urls with different permissions

https://example.com/mvsz1vqpyxdh52eogfucnxape5pjnj7b/video/video.mp4/640x480.m3u8
https://example.com/mvsz1vqpyxdh52eogfucnxape5pjnj7b/video/video.mp4/1280x720.m3u8
https://example.com/mvsz1vqpyxdh52eogfucnxape5pjnj7b/video/video.mp4/1920x1080.m3u8


I tried to artificially create a master manifest but it doesn't work
const manifestString = [
  '#EXTM3U',
  '#EXT-X-VERSION:4',
  '#EXT-X-STREAM-INF:BANDWIDTH=500,RESOLUTION=640x480',
  'https://example.com/mvsz1vqpyxdh52eogfucnxape5pjnj7b/video/video.mp4/640x480.m3u8',
  '#EXT-X-STREAM-INF:BANDWIDTH=1000,RESOLUTION=1280x720',
  'https://example.com/mvsz1vqpyxdh52eogfucnxape5pjnj7b/video/video.mp4/1280x720.m3u8',
  '#EXT-X-STREAM-INF:BANDWIDTH=2000,RESOLUTION=1920x1080',
  'https://example.com/mvsz1vqpyxdh52eogfucnxape5pjnj7b/video/video.mp4/1920x1080.m3u8'
].join('\n');
​
const parser = new m3u8Parser.Parser();
​
parser.push(manifestString);
parser.end();
​
const url = `data:application/vnd.videojs.vhs+json,${JSON.stringify(parser.manifest)}`;
const type = 'application/vnd.videojs.vhs+json';
const options = {
  html5: {
    hls: {
      smoothQualityChange: true,
      overrideNative: true
    }
  }
};
​
try {
  window.player = videojs('videoId', options);
​
  window.player.src({
    src: url,
    type: type
  });
} catch(err) {
  console.log("caught an error trying to create and add src to player:", err);
}


How can I get this to work?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ttm, 2020-03-26
@TouchTheMind

const manifestString = [
    '#EXTM3U',
    '#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=586889,RESOLUTION=640x480',
    'https://example.com/mvsz1vqpyxdh52eogfucnxape5pjnj7b/video/video.mp4/640x480.m3u8',
    '#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2171914,RESOLUTION=1280x720',
    'https://example.com/mvsz1vqpyxdh52eogfucnxape5pjnj7b/video/video.mp4/1280x720.m3u8',
    '#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=3192876,RESOLUTION=1920x1080',
    'https://example.com/mvsz1vqpyxdh52eogfucnxape5pjnj7b/video/video.mp4/1920x1080.m3u8'
].join('\n');
const url = 'data:application/x-mpegURL;base64,' + btoa(manifestString);
const type = 'application/x-mpegURL'';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question