Skip to content

Commit

Permalink
force 48k audio rate
Browse files Browse the repository at this point in the history
  • Loading branch information
vpalmisano committed Oct 16, 2024
1 parent adcc35a commit 01cdbff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions scripts/get-user-media.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand All @@ -30,23 +38,15 @@ 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)}`)
}

/**
* overrideGetDisplayMedia
* @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) {
Expand Down
2 changes: 1 addition & 1 deletion src/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
)
Expand Down

0 comments on commit 01cdbff

Please sign in to comment.