Bug 217147

Summary: getUserMedia with sampleRate constraints may fail
Product: WebKit Reporter: Marcos G. <marcosdg3>
Component: WebRTCAssignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: eric.carlson, ews-watchlist, glenn, hta, jer.noble, philipj, sergio, tommyw, webkit-bug-importer, youennf, zach
Priority: P2 Keywords: InRadar
Version: Safari 14   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Video file downloaded from codepen.
none
Patch none

Description Marcos G. 2020-09-30 15:16:18 PDT
Created attachment 410156 [details]
Video file downloaded from codepen.

I attempted to specify the mediastream constraints using: 

navigator.mediaDevices.getUserMedia({
                    audio: {
                        sampleRate: 24000,
                        echoCancellation: true
                    },
                    video: {
                        width: {
                            min: 480,
                            ideal: 640,
                            max: 800
                        },
                        height: {
                            min: 360,
                            ideal: 480,
                            max: 600
                        },
                        frameRate: 16,
                        aspectRatio: (4 / 3)
                    }
                })


No sound is recorded.

Ex: https://codepen.io/marcosdg3/pen/jOqogQd

ffprobe:

$ ffprobe test-8.mp4 
ffprobe version 4.2.2 Copyright (c) 2007-2019 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.17)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2_2 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test-8.mp4':
  Metadata:
    major_brand     : iso5
    minor_version   : 1
    compatible_brands: isomiso5hlsf
    creation_time   : 2020-09-30T22:14:51.000000Z
  Duration: 81:07:26.76, start: 292045.840000, bitrate: 0 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 0 kb/s, 15.29 fps, 15 tbr, 600 tbn, 1200 tbc (default)
    Metadata:
      creation_time   : 2020-09-30T22:14:51.000000Z
      handler_name    : Core Media Video
Comment 1 Marcos G. 2020-09-30 15:24:23 PDT
Confirmed audio:true works.
Comment 2 Radar WebKit Bug Importer 2020-10-01 04:06:44 PDT
<rdar://problem/69831144>
Comment 3 youenn fablet 2020-10-01 04:16:13 PDT
From my testing on macOS, it seems that {{audio : {sampleRate : 24000}} is the issue: audio capture does not work.
Comment 4 youenn fablet 2020-10-01 04:16:35 PDT
This seems also to require restarting Safari to enable capture again.
Comment 5 youenn fablet 2020-10-01 04:21:16 PDT
From the logs: "53771	error	13:20:25.675570+0200	Safari	 unsupported Out sample rate"
Comment 6 youenn fablet 2020-10-01 04:23:33 PDT
So the MediaStreamTrack ends due to capture failing.
Comment 7 youenn fablet 2020-10-01 05:38:58 PDT
Created attachment 410221 [details]
Patch
Comment 8 EWS 2020-10-01 10:07:05 PDT
Committed r267838: <https://trac.webkit.org/changeset/267838>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 410221 [details].