Skip to content

Commit 65f8969

Browse files
StaZhualvestrand
andauthored
Don't ajust audio track if there is no audio track (webrtc#1691)
On a M4 Mac Mini, there is no built-in microphone or camera, so `getAudioTracks()` will always return an empty array. In this case, we don't need to ajust sampling rate to 48khz... Also change av1 codecs string from `av01.1.x.y` to `av01.0.x.y` since MediaRecorder only support av1 main profile instead of high profile. Co-authored-by: Harald Alvestrand <hta@google.com>
1 parent 161f6e7 commit 65f8969

File tree

1 file changed

+9
-7
lines changed
  • src/content/getusermedia/record/js

1 file changed

+9
-7
lines changed

src/content/getusermedia/record/js/main.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function getSupportedMimeTypes() {
9393
'video/mp4;codecs=avc3.64003E,mp4a.40.2',
9494
'video/mp4;codecs=hvc1.1.6.L186.B0,mp4a.40.2',
9595
'video/mp4;codecs=hev1.1.6.L186.B0,mp4a.40.2',
96-
'video/mp4;codecs=av01.1.19M.08,mp4a.40.2',
96+
'video/mp4;codecs=av01.0.19M.08,mp4a.40.2',
9797
'video/mp4',
9898
];
9999
return possibleTypes.filter(mimeType => {
@@ -108,12 +108,14 @@ async function startRecording() {
108108
if (mimeType.split(';', 1)[0] === 'video/mp4') {
109109
// Adjust sampling rate to 48khz.
110110
const track = window.stream.getAudioTracks()[0];
111-
const {sampleRate} = track.getSettings();
112-
if (sampleRate != 48000) {
113-
track.stop();
114-
window.stream.removeTrack(track);
115-
const newStream = await navigator.mediaDevices.getUserMedia({audio: {sampleRate: 48000}});
116-
window.stream.addTrack(newStream.getTracks()[0]);
111+
if (track) {
112+
const {sampleRate} = track.getSettings();
113+
if (sampleRate != 48000) {
114+
track.stop();
115+
window.stream.removeTrack(track);
116+
const newStream = await navigator.mediaDevices.getUserMedia({audio: {sampleRate: 48000}});
117+
window.stream.addTrack(newStream.getTracks()[0]);
118+
}
117119
}
118120
}
119121
try {

0 commit comments

Comments
 (0)