@eluvio/elv-client-js 4.2.33 → 4.2.36

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.
@@ -221,7 +221,8 @@ var LiveConf = /*#__PURE__*/function () {
221
221
  *
222
222
  * Live input formats have fixed timebase:
223
223
  * - MPEG-TS/SRT input stream timebase is 90000
224
- * - RTMP input stream timebase is 1000 and gets translated to 16000 if not otherwise specified
224
+ * - RTMP input stream timebase is 1000 and gets translated to match the frame rate
225
+ * (eg. 24000 @24fps, 30000 @30fps/29.97fps, 60000 @60fps/59.94fps)
225
226
  *
226
227
  * This causes frame duration irregularities for certain frame rates.
227
228
  * For example RTMP 60fps has frames of durations 16 and 17. MPEG-TS 59.94fps has frames of
@@ -232,10 +233,13 @@ var LiveConf = /*#__PURE__*/function () {
232
233
  * to make the math possible. This adjustment is also required for live-to-vod conversion.
233
234
  *
234
235
  * For example for MPEG-TS 59.94fps, the mez segment timebase needs to be 60000
235
- * (and resulting frame duration is 1001) and for RTMP 60fps the timebase needs to be 15360 (resulting frame
236
- * duration is 256).
236
+ * (and resulting frame duration is 1001) and for RTMP 60fps the timebase is set to 60000
237
+ * (resulting frame duration is 1000). For every supported RTMP frame rate, the video timebase is
238
+ * set equal to the source timescale, with a frame duration of 1000 (1001 for the *000/1001
239
+ * fractional rates).
237
240
  *
238
- * @sourceTimescale - adjusted source video stream timescale (eg. MPEGTS 90000, RTMP 16000 )
241
+ * @sourceTimescale - adjusted source video stream timescale (eg. MPEGTS 90000; ignored for RTMP,
242
+ * which derives its own timebase per frame rate in calcSegDurationRtmp)
239
243
  * @sampleRate - audio sample rate (commonly 48000 but can be different)
240
244
  * @audioCodec - audio codec as a string (eg. "aac")
241
245
  * @return - segment encoding parameters
@@ -350,57 +354,64 @@ var LiveConf = /*#__PURE__*/function () {
350
354
  }
351
355
  }, {
352
356
  key: "calcSegDurationRtmp",
353
- value: function calcSegDurationRtmp(_ref5) {
354
- var sourceTimescale = _ref5.sourceTimescale;
357
+ value: function calcSegDurationRtmp() {
355
358
  var videoStream = this.getStreamDataForCodecType("video");
356
359
  var frameRate = videoStream.frame_rate;
357
360
  var seg = {};
358
361
  switch (frameRate) {
359
362
  case "24":
360
- seg.videoTimeBase = 768; // Note 1536 produces low output bitrate
361
- seg.videoFrameDurationTs = 512;
362
- seg.video = this.calcOutputTimebase(seg.videoTimeBase) * 30;
363
+ seg.videoTimeBase = 24000;
364
+ seg.videoFrameDurationTs = 1000;
365
+ seg.video = seg.videoTimeBase * 30;
363
366
  seg.keyint = 48;
364
367
  seg.duration = "30";
365
368
  break;
366
369
  case "25":
367
- seg.video = sourceTimescale * 30;
370
+ seg.videoTimeBase = 25000;
371
+ seg.videoFrameDurationTs = 1000;
372
+ seg.video = seg.videoTimeBase * 30;
368
373
  seg.keyint = 50;
369
374
  seg.duration = "30";
370
375
  break;
371
376
  case "30":
372
- seg.videoTimeBase = 960; // Output timebase: 15360
373
- seg.videoFrameDurationTs = 512;
374
- seg.video = this.calcOutputTimebase(seg.videoTimeBase) * 30;
377
+ seg.videoTimeBase = 30000;
378
+ seg.videoFrameDurationTs = 1000;
379
+ seg.video = seg.videoTimeBase * 30;
375
380
  seg.keyint = 60;
376
381
  seg.duration = "30";
377
382
  break;
378
383
  case "30000/1001":
379
- seg.video = sourceTimescale * 30.03;
384
+ seg.videoTimeBase = 30000;
385
+ seg.videoFrameDurationTs = 1001;
386
+ seg.video = seg.videoTimeBase * 30.03;
380
387
  seg.keyint = 60;
381
388
  seg.duration = "30.03";
382
389
  break;
383
390
  case "48":
384
- seg.videoTimeBase = 1536; // Output timebase: 12288
385
- seg.videoFrameDurationTs = 256;
386
- seg.video = this.calcOutputTimebase(seg.videoTimeBase) * 30;
391
+ seg.videoTimeBase = 48000;
392
+ seg.videoFrameDurationTs = 1000;
393
+ seg.video = seg.videoTimeBase * 30;
387
394
  seg.keyint = 96;
388
395
  seg.duration = "30";
389
396
  break;
390
397
  case "50":
391
- seg.video = sourceTimescale * 30;
398
+ seg.videoTimeBase = 50000;
399
+ seg.videoFrameDurationTs = 1000;
400
+ seg.video = seg.videoTimeBase * 30;
392
401
  seg.keyint = 100;
393
402
  seg.duration = "30";
394
403
  break;
395
404
  case "60":
396
- seg.videoTimeBase = 960; // Output timebase: 15360
397
- seg.videoFrameDurationTs = 256;
398
- seg.video = this.calcOutputTimebase(seg.videoTimeBase) * 30;
405
+ seg.videoTimeBase = 60000;
406
+ seg.videoFrameDurationTs = 1000;
407
+ seg.video = seg.videoTimeBase * 30;
399
408
  seg.keyint = 120;
400
409
  seg.duration = "30";
401
410
  break;
402
411
  case "60000/1001":
403
- seg.video = sourceTimescale * 30.03;
412
+ seg.videoTimeBase = 60000;
413
+ seg.videoFrameDurationTs = 1001;
414
+ seg.video = seg.videoTimeBase * 30.03;
404
415
  seg.keyint = 120;
405
416
  seg.duration = "30.03";
406
417
  break;
@@ -432,8 +443,8 @@ var LiveConf = /*#__PURE__*/function () {
432
443
  */
433
444
  }, {
434
445
  key: "MapCustomProfileToLiveConfig",
435
- value: function MapCustomProfileToLiveConfig(_ref6) {
436
- var customProfile = _ref6.customProfile;
446
+ value: function MapCustomProfileToLiveConfig(_ref5) {
447
+ var customProfile = _ref5.customProfile;
437
448
  if (!customProfile) return {};
438
449
  var CompactDeep = function CompactDeep(obj) {
439
450
  if (obj === null || _typeof(obj) !== "object" || Array.isArray(obj)) {
@@ -469,9 +480,9 @@ var LiveConf = /*#__PURE__*/function () {
469
480
  */
470
481
  }, {
471
482
  key: "generateAudioStreamsConfig",
472
- value: function generateAudioStreamsConfig(_ref7) {
483
+ value: function generateAudioStreamsConfig(_ref6) {
473
484
  var _liveRecordingConfigP, _liveRecordingConfigP2;
474
- var liveRecordingConfigProfile = _ref7.liveRecordingConfigProfile;
485
+ var liveRecordingConfigProfile = _ref6.liveRecordingConfigProfile;
475
486
  var ladderProfile = (liveRecordingConfigProfile === null || liveRecordingConfigProfile === void 0 || (_liveRecordingConfigP = liveRecordingConfigProfile.playout_config) === null || _liveRecordingConfigP === void 0 ? void 0 : _liveRecordingConfigP.ladder_specs) || DefaultABRLadder;
476
487
  var audioSettings = liveRecordingConfigProfile === null || liveRecordingConfigProfile === void 0 || (_liveRecordingConfigP2 = liveRecordingConfigProfile.recording_stream_config) === null || _liveRecordingConfigP2 === void 0 ? void 0 : _liveRecordingConfigP2.audio;
477
488
  var audioStreams = {};
@@ -513,9 +524,9 @@ var LiveConf = /*#__PURE__*/function () {
513
524
  */
514
525
  }, {
515
526
  key: "generateLiveConf",
516
- value: function generateLiveConf(_ref8) {
517
- var _customSettings$liveR, _customSettings$liveR2, _ladder_specs$video;
518
- var customSettings = _ref8.customSettings;
527
+ value: function generateLiveConf(_ref7) {
528
+ var _customSettings$liveR, _customXcParams$enc_h, _customXcParams$enc_w, _customRecordingParam, _customRecordingParam2, _customSettings$liveR2, _customXcParams$video, _customSettings$liveR3, _ladder_specs$video;
529
+ var customSettings = _ref7.customSettings;
519
530
  // Saved config overrides defaults and is preserved on reconfiguration
520
531
  var conf = R.clone(LiveconfTemplate);
521
532
  if (this.currentLiveRecordingMeta) {
@@ -540,6 +551,10 @@ var LiveConf = /*#__PURE__*/function () {
540
551
  var videoStream = this.getStreamDataForCodecType("video");
541
552
  var sourceTimescale;
542
553
 
554
+ // Custom profile values take precedence over computed defaults
555
+ var customRecordingParams = (_customSettings$liveR = customSettings.liveRecordingConfigProfile) === null || _customSettings$liveR === void 0 ? void 0 : _customSettings$liveR.recording_params;
556
+ var customXcParams = customRecordingParams === null || customRecordingParams === void 0 ? void 0 : customRecordingParams.xc_params;
557
+
543
558
  // Fill in liveconf all formats have in common
544
559
  conf.live_recording.fabric_config.ingress_node_api = this.nodeUrl || null;
545
560
  conf.live_recording.fabric_config.ingress_node_id = this.nodeId || null;
@@ -548,8 +563,10 @@ var LiveConf = /*#__PURE__*/function () {
548
563
  conf.live_recording.recording_config.recording_params.description = "Ingest stream ".concat(fileName);
549
564
  conf.live_recording.recording_config.recording_params.name = "Ingest stream ".concat(fileName);
550
565
  conf.live_recording.recording_config.recording_params.xc_params.sample_rate = sampleRate;
551
- conf.live_recording.recording_config.recording_params.xc_params.enc_height = videoStream.height;
552
- conf.live_recording.recording_config.recording_params.xc_params.enc_width = videoStream.width;
566
+
567
+ // Encoding dimensions default to the source but are overridden by profile values if present
568
+ conf.live_recording.recording_config.recording_params.xc_params.enc_height = (_customXcParams$enc_h = customXcParams === null || customXcParams === void 0 ? void 0 : customXcParams.enc_height) !== null && _customXcParams$enc_h !== void 0 ? _customXcParams$enc_h : videoStream.height;
569
+ conf.live_recording.recording_config.recording_params.xc_params.enc_width = (_customXcParams$enc_w = customXcParams === null || customXcParams === void 0 ? void 0 : customXcParams.enc_width) !== null && _customXcParams$enc_w !== void 0 ? _customXcParams$enc_w : videoStream.width;
553
570
  for (var i = 0; i < Object.keys(audioStreams).length; i++) {
554
571
  conf.live_recording.recording_config.recording_params.xc_params.audio_index[i] = parseInt(Object.keys(audioStreams)[i]);
555
572
  }
@@ -560,12 +577,12 @@ var LiveConf = /*#__PURE__*/function () {
560
577
  // Fill in specifics for protocol
561
578
  switch (this.getFormat()) {
562
579
  case "mpegts":
563
- sourceTimescale = 90000;
580
+ sourceTimescale = (_customRecordingParam = customRecordingParams === null || customRecordingParams === void 0 ? void 0 : customRecordingParams.source_timescale) !== null && _customRecordingParam !== void 0 ? _customRecordingParam : 90000;
564
581
  conf.live_recording.recording_config.recording_params.source_timescale = sourceTimescale;
565
582
  break;
566
583
  case "rtmp":
567
584
  case "flv":
568
- sourceTimescale = 16000;
585
+ sourceTimescale = (_customRecordingParam2 = customRecordingParams === null || customRecordingParams === void 0 ? void 0 : customRecordingParams.source_timescale) !== null && _customRecordingParam2 !== void 0 ? _customRecordingParam2 : 16000;
569
586
  conf.live_recording.recording_config.recording_params.source_timescale = sourceTimescale;
570
587
  break;
571
588
  case "hls":
@@ -577,7 +594,7 @@ var LiveConf = /*#__PURE__*/function () {
577
594
  }
578
595
  switch (this.getProtocol()) {
579
596
  case "srt":
580
- if (!((_customSettings$liveR = customSettings.liveRecordingConfigProfile) !== null && _customSettings$liveR !== void 0 && (_customSettings$liveR = _customSettings$liveR.recording_params) !== null && _customSettings$liveR !== void 0 && _customSettings$liveR.live_delay_nano)) {
597
+ if (!((_customSettings$liveR2 = customSettings.liveRecordingConfigProfile) !== null && _customSettings$liveR2 !== void 0 && (_customSettings$liveR2 = _customSettings$liveR2.recording_params) !== null && _customSettings$liveR2 !== void 0 && _customSettings$liveR2.live_delay_nano)) {
581
598
  conf.live_recording.recording_config.recording_params.live_delay_nano = 6000000000;
582
599
  }
583
600
  break;
@@ -591,23 +608,27 @@ var LiveConf = /*#__PURE__*/function () {
591
608
  // Segment conditioning parameters
592
609
  conf.live_recording.recording_config.recording_params.xc_params.seg_duration = segDurations.duration;
593
610
  conf.live_recording.recording_config.recording_params.xc_params.audio_seg_duration_ts = segDurations.audio;
594
- conf.live_recording.recording_config.recording_params.xc_params.video_seg_duration_ts = segDurations.video;
611
+ conf.live_recording.recording_config.recording_params.xc_params.video_seg_duration_ts = (_customXcParams$video = customXcParams === null || customXcParams === void 0 ? void 0 : customXcParams.video_seg_duration_ts) !== null && _customXcParams$video !== void 0 ? _customXcParams$video : segDurations.video;
595
612
  conf.live_recording.recording_config.recording_params.xc_params.force_keyint = segDurations.keyint;
596
613
 
597
- // Optional override output timebase and frame duration (ts)
598
- if (segDurations.videoTimeBase) {
599
- conf.live_recording.recording_config.recording_params.xc_params.video_time_base = segDurations.videoTimeBase;
614
+ // These must be recomputed from scratch on every (re)configuration to avoid stale values
615
+ if (R.isNil(customXcParams === null || customXcParams === void 0 ? void 0 : customXcParams.video_time_base)) {
616
+ if (segDurations.videoTimeBase) {
617
+ conf.live_recording.recording_config.recording_params.xc_params.video_time_base = segDurations.videoTimeBase;
600
618
 
601
- // Note 'source_timescale' needs to be set to the output timebase and is used by playout
602
- conf.live_recording.recording_config.recording_params.source_timescale = this.calcOutputTimebase(segDurations.videoTimeBase);
619
+ // Note 'source_timescale' needs to be set to the output timebase and is used by playout
620
+ if (R.isNil(customRecordingParams === null || customRecordingParams === void 0 ? void 0 : customRecordingParams.source_timescale)) {
621
+ conf.live_recording.recording_config.recording_params.source_timescale = this.calcOutputTimebase(segDurations.videoTimeBase);
622
+ }
623
+ } else {
624
+ conf.live_recording.recording_config.recording_params.xc_params.video_time_base = null;
625
+ }
603
626
  }
604
- if (segDurations.videoFrameDurationTs) {
605
- conf.live_recording.recording_config.recording_params.xc_params.video_frame_duration_ts = segDurations.videoFrameDurationTs;
627
+ if (R.isNil(customXcParams === null || customXcParams === void 0 ? void 0 : customXcParams.video_frame_duration_ts)) {
628
+ conf.live_recording.recording_config.recording_params.xc_params.video_frame_duration_ts = segDurations.videoFrameDurationTs || null;
606
629
  }
607
- var ladder_specs = (_customSettings$liveR2 = customSettings.liveRecordingConfigProfile) === null || _customSettings$liveR2 === void 0 || (_customSettings$liveR2 = _customSettings$liveR2.playout_config) === null || _customSettings$liveR2 === void 0 ? void 0 : _customSettings$liveR2.ladder_specs;
630
+ var ladder_specs = (_customSettings$liveR3 = customSettings.liveRecordingConfigProfile) === null || _customSettings$liveR3 === void 0 || (_customSettings$liveR3 = _customSettings$liveR3.playout_config) === null || _customSettings$liveR3 === void 0 ? void 0 : _customSettings$liveR3.ladder_specs;
608
631
  var ladderProfile = (ladder_specs === null || ladder_specs === void 0 || (_ladder_specs$video = ladder_specs.video) === null || _ladder_specs$video === void 0 ? void 0 : _ladder_specs$video.length) > 0 ? ladder_specs : DefaultABRLadder;
609
- conf.live_recording.recording_config.recording_params.xc_params.enc_height = videoStream.height;
610
- conf.live_recording.recording_config.recording_params.xc_params.enc_width = videoStream.width;
611
632
 
612
633
  // Reset ladder specs (updating existing stream will carry over old specs
613
634
  conf.live_recording.recording_config.recording_params.ladder_specs = [];