MediaRecorder 无故改变大小

MediaRecorder changes size without provocation

我正在使用 MediaRecorder API along with the Canvas captureStream 方法在浏览器中对 canvas 的 VP8 视频流进行编码。此数据通过二进制网络套接字发送到 FFmpeg。

var outputCaptureStream = $('canvas')[0].captureStream(30);
var mediaRecoder = new MediaRecoder(outputCaptureStream, {
  mimeType: 'video/webm'
});

mediaRecorder.ondataavailable = function (e) {
  ffmpegStdin.write(e.data);
}

mediaRecoder.start(1000);

由于某种原因,流似乎随机切换到分辨率较低的中流。 FFmpeg 对此不满意:

Input stream #0:0 frame changed from size:1280x720 fmt:yuv420p to size:1024x576 fmt:yuv420p

[vp8 @ 0x2a02c00] Upscaling is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented. [vp8 @ 0x2a02c00] If you want to help, upload a sample of this file to ftp://upload.ffmpeg.org/incoming/ and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)

我怀疑这与过度使用 CPU 有关,并且 Firefox 正试图通过缩小视频来提供帮助。我的问题:

如果 Firefox 检测到系统 CPU 过载,它将重新调整(缩小)WebRTC/getUserMedia 视频。 about:config 中有一些首选项可以控制此行为,但无法通过 JS 控制。

您可以通过设置

禁用该功能

media.navigator.load_adapt=假

您可以查看其他 media.navigator.load_adapt.* 标志以控制行为。默认情况下,如果 CPU 超过 90% 并持续 3 秒,您将进行缩减。