MediaRecorder resizes without provocation

I use the MediaRecorder API along with the Canvas captureStream method to encode a VP8 video canvas stream in a browser. This data is sent to FFmpeg via a binary web socket.

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); 

For some reason, the stream seems to accidentally switch to a lower-resolution medium stream. FFmpeg is not happy with this:

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

[vp8 @ 0x2a02c00] Acceleration is not implemented. Upgrade your FFmpeg version to the latest version from Git. If the problem still occurs, it means that there is a function in your file that has not been implemented. [vp8 @ 0x2a02c00] If you want to help, upload a sample of this file to ftp://upload.ffmpeg.org/incoming/ and go to the ffmpeg-devel mailing list. ( Ffmpeg-devel@ffmpeg.org )

I suspect that it has something to do with excessive CPU usage and that Firefox is trying to help by downsizing the video. My questions:

  • Does Firefox scan video on the fly?
  • If so, what conditions cause this? (CPU usage? Reset back pressure?)
  • Is it possible to prevent Firefox from doing this?
  • Is there any other explanation for this behavior that I am missing?
+5
source share
1 answer

Firefox will scale (downsize) the WebRTC / getUserMedia video if it detects that the system processor is overloaded. There are several prefixes in: config that control this behavior, but are not controlled through JS.

You can disable this feature by setting

media.navigator.load_adapt = false

You can see other flags of media.navigator.load_adapt. * for some control over the behavior. By default, you will get scaling if the processor is tied more than 90% in 3 seconds.

+3
source

Source: https://habr.com/ru/post/1242319/


All Articles