hls.js 1.5.14-0.canary.10598 → 1.5.14-0.canary.10602

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -393,6 +393,28 @@ To check for native browser support first and then fallback to HLS.js, swap thes
393
393
  </script>
394
394
  ```
395
395
 
396
+ #### Ensure correct time in video
397
+
398
+ HLS transcoding of an original video file often pushes the time of the first frame a bit. If you depend on having an exact match of frame times between original video and HLS stream, you need to account for this:
399
+
400
+ ```javascript
401
+ let tOffset = 0;
402
+ const getAppendedOffset = (eventName, { frag }) => {
403
+ if (frag.type === 'main' && frag.sn !== 'initSegment' && frag.elementaryStreams.video) {
404
+ const { start, startDTS, startPTS, maxStartPTS, elementaryStreams } = frag;
405
+ tOffset = elementaryStreams.video.startPTS - start;
406
+ hls.off(Hls.Events.BUFFER_APPENDED, getAppendedOffset);
407
+ console.log('video timestamp offset:', tOffset, { start, startDTS, startPTS, maxStartPTS, elementaryStreams });
408
+ }
409
+ }
410
+ hls.on(Hls.Events.BUFFER_APPENDED, getAppendedOffset);
411
+ // and account for this offset, for example like this:
412
+ const video = document.querySelector('video');
413
+ video.addEventListener('timeupdate', () => setTime(Math.max(0, video.currentTime - tOffset))
414
+ const seek = (t) => video.currentTime = t + tOffset;
415
+ const getDuration = () => video.duration - tOffset;
416
+ ```
417
+
396
418
  For more embed and API examples see [docs/API.md](./docs/API.md).
397
419
 
398
420
  ## CORS
package/dist/hls.d.mts CHANGED
@@ -1395,6 +1395,7 @@ declare class Hls implements HlsEventEmitter {
1395
1395
  */
1396
1396
  static getMediaSource(): typeof MediaSource | undefined;
1397
1397
  static get Events(): typeof Events;
1398
+ static get MetadataSchema(): typeof MetadataSchema;
1398
1399
  static get ErrorTypes(): typeof ErrorTypes;
1399
1400
  static get ErrorDetails(): typeof ErrorDetails;
1400
1401
  /**
@@ -2445,6 +2446,7 @@ export declare type MediaPlaylistType = MainPlaylistType | SubtitlePlaylistType;
2445
2446
  export declare type MetadataControllerConfig = {
2446
2447
  enableDateRangeMetadataCues: boolean;
2447
2448
  enableEmsgMetadataCues: boolean;
2449
+ enableEmsgKLVMetadata: boolean;
2448
2450
  enableID3MetadataCues: boolean;
2449
2451
  };
2450
2452
 
@@ -2457,10 +2459,11 @@ export declare interface MetadataSample {
2457
2459
  type: MetadataSchema;
2458
2460
  }
2459
2461
 
2460
- export declare const enum MetadataSchema {
2462
+ export declare enum MetadataSchema {
2461
2463
  audioId3 = "org.id3",
2462
2464
  dateRange = "com.apple.quicktime.HLS",
2463
- emsg = "https://aomedia.org/emsg/ID3"
2465
+ emsg = "https://aomedia.org/emsg/ID3",
2466
+ misbklv = "urn:misb:KLV:bin:1910.1"
2464
2467
  }
2465
2468
 
2466
2469
  export declare type MP4RemuxerConfig = {
package/dist/hls.d.ts CHANGED
@@ -1395,6 +1395,7 @@ declare class Hls implements HlsEventEmitter {
1395
1395
  */
1396
1396
  static getMediaSource(): typeof MediaSource | undefined;
1397
1397
  static get Events(): typeof Events;
1398
+ static get MetadataSchema(): typeof MetadataSchema;
1398
1399
  static get ErrorTypes(): typeof ErrorTypes;
1399
1400
  static get ErrorDetails(): typeof ErrorDetails;
1400
1401
  /**
@@ -2445,6 +2446,7 @@ export declare type MediaPlaylistType = MainPlaylistType | SubtitlePlaylistType;
2445
2446
  export declare type MetadataControllerConfig = {
2446
2447
  enableDateRangeMetadataCues: boolean;
2447
2448
  enableEmsgMetadataCues: boolean;
2449
+ enableEmsgKLVMetadata: boolean;
2448
2450
  enableID3MetadataCues: boolean;
2449
2451
  };
2450
2452
 
@@ -2457,10 +2459,11 @@ export declare interface MetadataSample {
2457
2459
  type: MetadataSchema;
2458
2460
  }
2459
2461
 
2460
- export declare const enum MetadataSchema {
2462
+ export declare enum MetadataSchema {
2461
2463
  audioId3 = "org.id3",
2462
2464
  dateRange = "com.apple.quicktime.HLS",
2463
- emsg = "https://aomedia.org/emsg/ID3"
2465
+ emsg = "https://aomedia.org/emsg/ID3",
2466
+ misbklv = "urn:misb:KLV:bin:1910.1"
2464
2467
  }
2465
2468
 
2466
2469
  export declare type MP4RemuxerConfig = {
package/dist/hls.js CHANGED
@@ -523,7 +523,7 @@
523
523
  // Some browsers don't allow to use bind on console object anyway
524
524
  // fallback to default if needed
525
525
  try {
526
- newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.5.14-0.canary.10598");
526
+ newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.5.14-0.canary.10602");
527
527
  } catch (e) {
528
528
  /* log fn threw an exception. All logger methods are no-ops. */
529
529
  return createLogger();
@@ -4542,11 +4542,13 @@
4542
4542
  return tracks;
4543
4543
  }
4544
4544
 
4545
- var MetadataSchema = {
4546
- audioId3: "org.id3",
4547
- dateRange: "com.apple.quicktime.HLS",
4548
- emsg: "https://aomedia.org/emsg/ID3"
4549
- };
4545
+ var MetadataSchema = /*#__PURE__*/function (MetadataSchema) {
4546
+ MetadataSchema["audioId3"] = "org.id3";
4547
+ MetadataSchema["dateRange"] = "com.apple.quicktime.HLS";
4548
+ MetadataSchema["emsg"] = "https://aomedia.org/emsg/ID3";
4549
+ MetadataSchema["misbklv"] = "urn:misb:KLV:bin:1910.1";
4550
+ return MetadataSchema;
4551
+ }({});
4550
4552
 
4551
4553
  /**
4552
4554
  * Decode an ID3 PRIV frame.
@@ -12177,6 +12179,7 @@
12177
12179
  };
12178
12180
  };
12179
12181
  _proto.extractID3Track = function extractID3Track(videoTrack, timeOffset) {
12182
+ var _this = this;
12180
12183
  var id3Track = this.id3Track;
12181
12184
  if (videoTrack.samples.length) {
12182
12185
  var emsgs = findBox(videoTrack.samples, ['emsg']);
@@ -12199,6 +12202,16 @@
12199
12202
  type: MetadataSchema.emsg,
12200
12203
  duration: duration
12201
12204
  });
12205
+ } else if (_this.config.enableEmsgKLVMetadata && emsgInfo.schemeIdUri.startsWith('urn:misb:KLV:bin:1910.1')) {
12206
+ var _pts = isFiniteNumber(emsgInfo.presentationTime) ? emsgInfo.presentationTime / emsgInfo.timeScale : timeOffset + emsgInfo.presentationTimeDelta / emsgInfo.timeScale;
12207
+ id3Track.samples.push({
12208
+ data: emsgInfo.payload,
12209
+ len: emsgInfo.payload.byteLength,
12210
+ dts: _pts,
12211
+ pts: _pts,
12212
+ type: MetadataSchema.misbklv,
12213
+ duration: Number.POSITIVE_INFINITY
12214
+ });
12202
12215
  }
12203
12216
  });
12204
12217
  }
@@ -17311,7 +17324,7 @@
17311
17324
  return !remuxResult.audio && !remuxResult.video && !remuxResult.text && !remuxResult.id3 && !remuxResult.initSegment;
17312
17325
  }
17313
17326
 
17314
- var version = "1.5.14-0.canary.10598";
17327
+ var version = "1.5.14-0.canary.10602";
17315
17328
 
17316
17329
  // ensure the worker ends up in the bundle
17317
17330
  // If the worker should not be included this gets aliased to empty.js
@@ -27462,6 +27475,7 @@
27462
27475
  cmcd: undefined,
27463
27476
  enableDateRangeMetadataCues: true,
27464
27477
  enableEmsgMetadataCues: true,
27478
+ enableEmsgKLVMetadata: false,
27465
27479
  enableID3MetadataCues: true,
27466
27480
  useMediaCapabilities: true,
27467
27481
  certLoadPolicy: {
@@ -30920,6 +30934,11 @@
30920
30934
  get: function get() {
30921
30935
  return Events;
30922
30936
  }
30937
+ }, {
30938
+ key: "MetadataSchema",
30939
+ get: function get() {
30940
+ return MetadataSchema;
30941
+ }
30923
30942
  }, {
30924
30943
  key: "ErrorTypes",
30925
30944
  get: function get() {
package/dist/hls.js.d.ts CHANGED
@@ -1395,6 +1395,7 @@ declare class Hls implements HlsEventEmitter {
1395
1395
  */
1396
1396
  static getMediaSource(): typeof MediaSource | undefined;
1397
1397
  static get Events(): typeof Events;
1398
+ static get MetadataSchema(): typeof MetadataSchema;
1398
1399
  static get ErrorTypes(): typeof ErrorTypes;
1399
1400
  static get ErrorDetails(): typeof ErrorDetails;
1400
1401
  /**
@@ -2445,6 +2446,7 @@ export declare type MediaPlaylistType = MainPlaylistType | SubtitlePlaylistType;
2445
2446
  export declare type MetadataControllerConfig = {
2446
2447
  enableDateRangeMetadataCues: boolean;
2447
2448
  enableEmsgMetadataCues: boolean;
2449
+ enableEmsgKLVMetadata: boolean;
2448
2450
  enableID3MetadataCues: boolean;
2449
2451
  };
2450
2452
 
@@ -2457,10 +2459,11 @@ export declare interface MetadataSample {
2457
2459
  type: MetadataSchema;
2458
2460
  }
2459
2461
 
2460
- export declare const enum MetadataSchema {
2462
+ export declare enum MetadataSchema {
2461
2463
  audioId3 = "org.id3",
2462
2464
  dateRange = "com.apple.quicktime.HLS",
2463
- emsg = "https://aomedia.org/emsg/ID3"
2465
+ emsg = "https://aomedia.org/emsg/ID3",
2466
+ misbklv = "urn:misb:KLV:bin:1910.1"
2464
2467
  }
2465
2468
 
2466
2469
  export declare type MP4RemuxerConfig = {