From 01cdbff7baa6c2f30d17c2919202f10e6d5e59be Mon Sep 17 00:00:00 2001 From: Vittorio Palmisano Date: Wed, 16 Oct 2024 22:31:20 +0200 Subject: [PATCH] force 48k audio rate --- scripts/get-user-media.js | 16 ++++++++-------- src/media.ts | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/get-user-media.js b/scripts/get-user-media.js index 19deb52..dc79a0d 100644 --- a/scripts/get-user-media.js +++ b/scripts/get-user-media.js @@ -22,6 +22,14 @@ const applyOverride = (constraints, override) => { constraints.audio = override.audio } } + log(`applyOverride result:`, constraints) + } + // Force audio sample rate to 48kHz. + if (constraints.audio) { + if (!(constraints.audio instanceof Object)) { + constraints.audio = {} + } + constraints.audio.sampleRate = 48000 } } @@ -30,11 +38,7 @@ const applyOverride = (constraints, override) => { * @param {*} constraints */ function overrideGetUserMedia(constraints) { - if (!window.GET_USER_MEDIA_OVERRIDE) { - return - } applyOverride(constraints, window.GET_USER_MEDIA_OVERRIDE) - log(`getUserMedia override result: ${JSON.stringify(constraints, null, 2)}`) } /** @@ -42,11 +46,7 @@ function overrideGetUserMedia(constraints) { * @param {*} constraints */ function overrideGetDisplayMedia(constraints) { - if (!window.GET_DISPLAY_MEDIA_OVERRIDE) { - return - } applyOverride(constraints, window.GET_DISPLAY_MEDIA_OVERRIDE) - log(`getDisplayMedia override result: ${JSON.stringify(constraints, null, 2)}`) } async function applyGetDisplayMediaCrop(mediaStream) { diff --git a/src/media.ts b/src/media.ts index 747fc70..d4d57f3 100644 --- a/src/media.ts +++ b/src/media.ts @@ -87,7 +87,7 @@ export async function prepareFakeMedia({ ` -r ${videoFramerate}` + ` -ss ${videoSeek} -t ${videoDuration} -shortest -af apad` + ` ${videoMap} ${destVideoPathTmp}` + - ` ${audioMap} ${destAudioPathTmp}` + + ` ${audioMap} -ar 48000 ${destAudioPathTmp}` + ` && mv ${destVideoPathTmp} ${destVideoPath}` + ` && mv ${destAudioPathTmp} ${destAudioPath}`, )