@vidtreo/recorder 1.7.0 → 1.7.1

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +2088 -2084
  2. package/dist/index.js +24 -10
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1777,6 +1777,12 @@ async function resolveAudioCodecFromPolicy(options) {
1777
1777
  if (options.bitrate !== undefined) {
1778
1778
  audioCodecOptions.bitrate = options.bitrate;
1779
1779
  }
1780
+ if (options.numberOfChannels !== undefined) {
1781
+ audioCodecOptions.numberOfChannels = options.numberOfChannels;
1782
+ }
1783
+ if (options.sampleRate !== undefined) {
1784
+ audioCodecOptions.sampleRate = options.sampleRate;
1785
+ }
1780
1786
  const probeResults = await Promise.allSettled([
1781
1787
  getFirstEncodableAudioCodec(candidates, audioCodecOptions)
1782
1788
  ]);
@@ -6299,7 +6305,7 @@ function resolveDeviceError(input) {
6299
6305
  // package.json
6300
6306
  var package_default = {
6301
6307
  name: "@vidtreo/recorder",
6302
- version: "1.7.0",
6308
+ version: "1.7.1",
6303
6309
  type: "module",
6304
6310
  description: "Vidtreo SDK for browser-based video recording and transcoding. Features include camera/screen recording, real-time MP4 transcoding, audio level analysis, mute/pause controls, source switching, device selection, and automatic backend uploads. Similar to Ziggeo and Addpipe, Vidtreo provides enterprise-grade video processing capabilities for web applications.",
6305
6311
  main: "./dist/index.js",
@@ -21162,6 +21168,8 @@ var CODEC_CACHE_AUDIO_OVERRIDE = "audioOverride";
21162
21168
  var CODEC_CACHE_VIDEO_OVERRIDE = "videoOverride";
21163
21169
  var CODEC_CACHE_AUDIO_BITRATE = "audioBitrate";
21164
21170
  var CODEC_CACHE_VIDEO_BITRATE = "videoBitrate";
21171
+ var CODEC_CACHE_AUDIO_CHANNELS = "audioChannels";
21172
+ var CODEC_CACHE_AUDIO_SAMPLE_RATE = "audioSampleRate";
21165
21173
  var CODEC_CACHE_WIDTH = "width";
21166
21174
  var CODEC_CACHE_HEIGHT = "height";
21167
21175
  var CODEC_CACHE_POLICY_PREFERRED_AUDIO = "policyPreferredAudio";
@@ -21423,7 +21431,6 @@ class WorkerProcessor {
21423
21431
  isLinuxPlatform: this.isLinuxPlatformFn()
21424
21432
  });
21425
21433
  const audioBitrate = this.resolveAudioBitrate(config, format);
21426
- const audioCodec = await this.resolveAudioCodecWithCache(config, format, policy, audioBitrate);
21427
21434
  const codec = await this.resolveVideoCodecWithCache(config, format, policy);
21428
21435
  const isScreenCapture = isScreenCaptureStream(stream);
21429
21436
  logger.debug("[WorkerProcessor] Starting processing", {
@@ -21432,7 +21439,6 @@ class WorkerProcessor {
21432
21439
  codec,
21433
21440
  bitrate: config.bitrate
21434
21441
  });
21435
- const workerConfig = this.buildWorkerTranscodeConfig(config, audioCodec, audioBitrate, codec, format);
21436
21442
  if (typeof config.fps === "number" && config.fps > 0) {
21437
21443
  this.lastConfigFps = config.fps;
21438
21444
  }
@@ -21468,6 +21474,8 @@ class WorkerProcessor {
21468
21474
  };
21469
21475
  }
21470
21476
  const { audioConfig, audioStream, shouldStartAudioWorklet } = await this.prepareAudioPipeline(audioTrack, workerProbeResult);
21477
+ const audioCodec = await this.resolveAudioCodecWithCache(config, format, policy, audioBitrate, audioConfig);
21478
+ const workerConfig = this.buildWorkerTranscodeConfig(config, audioCodec, audioBitrate, codec, format);
21471
21479
  const overlayConfigToSend = this.buildOverlayConfigToSend();
21472
21480
  const message = createStartMessage({
21473
21481
  videoTrack: videoInput.videoTrack,
@@ -21727,12 +21735,14 @@ class WorkerProcessor {
21727
21735
  }
21728
21736
  return getPresetAudioBitrateForFormat(format);
21729
21737
  }
21730
- async resolveAudioCodec(config, format, policy, audioBitrate) {
21738
+ async resolveAudioCodec(config, format, policy, audioBitrate, audioConfig) {
21731
21739
  return await resolveAudioCodecFromPolicy({
21732
21740
  format,
21733
21741
  overrideCodec: config.audioCodec,
21734
21742
  policy,
21735
- bitrate: audioBitrate
21743
+ bitrate: audioBitrate,
21744
+ numberOfChannels: audioConfig?.numberOfChannels,
21745
+ sampleRate: audioConfig?.sampleRate
21736
21746
  });
21737
21747
  }
21738
21748
  async resolveVideoCodec(config, format, policy) {
@@ -21745,13 +21755,13 @@ class WorkerProcessor {
21745
21755
  bitrate: config.bitrate
21746
21756
  });
21747
21757
  }
21748
- async resolveAudioCodecWithCache(config, format, policy, audioBitrate) {
21749
- const audioCodecCacheKey = this.buildAudioCodecCacheKey(config, format, policy, audioBitrate);
21758
+ async resolveAudioCodecWithCache(config, format, policy, audioBitrate, audioConfig) {
21759
+ const audioCodecCacheKey = this.buildAudioCodecCacheKey(config, format, policy, audioBitrate, audioConfig);
21750
21760
  const cachedAudioCodec = resolvedAudioCodecCache.get(audioCodecCacheKey);
21751
21761
  if (cachedAudioCodec) {
21752
21762
  return cachedAudioCodec;
21753
21763
  }
21754
- const resolvedAudioCodec = await this.resolveAudioCodec(config, format, policy, audioBitrate);
21764
+ const resolvedAudioCodec = await this.resolveAudioCodec(config, format, policy, audioBitrate, audioConfig);
21755
21765
  setCodecCacheValue(resolvedAudioCodecCache, audioCodecCacheKey, resolvedAudioCodec);
21756
21766
  return resolvedAudioCodec;
21757
21767
  }
@@ -21765,15 +21775,19 @@ class WorkerProcessor {
21765
21775
  setCodecCacheValue(resolvedVideoCodecCache, videoCodecCacheKey, resolvedVideoCodec);
21766
21776
  return resolvedVideoCodec;
21767
21777
  }
21768
- buildAudioCodecCacheKey(config, format, policy, audioBitrate) {
21778
+ buildAudioCodecCacheKey(config, format, policy, audioBitrate, audioConfig) {
21769
21779
  const audioOverride = formatCacheValue(config.audioCodec);
21770
21780
  const preferredAudioCodec = formatCacheValue(policy.preferredAudioCodec);
21771
21781
  const audioFallbackOrder = formatCacheArray(policy.audioCodecFallbackOrder);
21772
21782
  const audioBitrateValue = formatCacheValue(audioBitrate);
21783
+ const audioChannelsValue = formatCacheValue(audioConfig?.numberOfChannels);
21784
+ const audioSampleRateValue = formatCacheValue(audioConfig?.sampleRate);
21773
21785
  return [
21774
21786
  buildCacheEntry(CODEC_CACHE_FORMAT, formatCacheValue(format)),
21775
21787
  buildCacheEntry(CODEC_CACHE_AUDIO_OVERRIDE, audioOverride),
21776
21788
  buildCacheEntry(CODEC_CACHE_AUDIO_BITRATE, audioBitrateValue),
21789
+ buildCacheEntry(CODEC_CACHE_AUDIO_CHANNELS, audioChannelsValue),
21790
+ buildCacheEntry(CODEC_CACHE_AUDIO_SAMPLE_RATE, audioSampleRateValue),
21777
21791
  buildCacheEntry(CODEC_CACHE_POLICY_PREFERRED_AUDIO, preferredAudioCodec),
21778
21792
  buildCacheEntry(CODEC_CACHE_POLICY_AUDIO_FALLBACK, audioFallbackOrder)
21779
21793
  ].join(CODEC_CACHE_KEY_SEPARATOR);
@@ -22202,7 +22216,7 @@ class WorkerProcessor {
22202
22216
  isLinuxPlatform: this.isLinuxPlatformFn()
22203
22217
  });
22204
22218
  const cacheAudioBitrate = this.resolveAudioBitrate(config, format);
22205
- this.resolveAudioCodecWithCache(config, format, cachePolicy, cacheAudioBitrate).catch(this.handleWarmupCacheError);
22219
+ this.resolveAudioCodecWithCache(config, format, cachePolicy, cacheAudioBitrate, null).catch(this.handleWarmupCacheError);
22206
22220
  this.resolveVideoCodecWithCache(config, format, cachePolicy).catch(this.handleWarmupCacheError);
22207
22221
  const workerConfig = this.buildWorkerTranscodeConfig(config, policy.preferredAudioCodec, audioBitrate, codec, format);
22208
22222
  const message = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vidtreo/recorder",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "type": "module",
5
5
  "description": "Vidtreo SDK for browser-based video recording and transcoding. Features include camera/screen recording, real-time MP4 transcoding, audio level analysis, mute/pause controls, source switching, device selection, and automatic backend uploads. Similar to Ziggeo and Addpipe, Vidtreo provides enterprise-grade video processing capabilities for web applications.",
6
6
  "main": "./dist/index.js",