首页 > 解决方案 > Electron 是否支持 4K USB 视频分辨率?

问题描述

我们正在使用 Electron 框架开发一个 Windows 应用程序。此应用程序旨在显示来自 USB 摄像头的视频流。我们正在使用“navigator.mediaDevices”api 来访问 USB 视频流。问题是 Electron 应用程序无法为 4K USB 视频分辨率工作并引发错误。

我们能够在 Electron 应用程序中看到视频流,但它仅适用于较低的分辨率,例如 480p,因此质量达不到标准。USB 摄像头可以支持到 4K 分辨率。但是,当我们提供更高分辨率时,它可以工作到 720p,但超出此范围会出现“OverconstrainedError”。(下面的代码片段用于 refn)

          navigator.mediaDevices.getUserMedia({
                video:
                    {

                            width: {
                                exact: usbWidth // works till 1280
                            },
                            height: {
                                exact: usbHeight // works till 720

                            },
                            deviceId: {
                            exact: deviceid
                        },

                    }
            }).then(function (stream) {
                stream.getTracks().forEach(function(track) {
                    console.log(track.getSettings());
            })

我的问题是:

  1. 建立在 Chromium 之上的 Electron 在 USB 视频分辨率方面是否有任何限制?

  2. Electron 应用中是否支持 4K USB 视频分辨率?

  3. 是否有任何参考代码可以为我们指明正确的方向?

这是 FFMPEG 命令的响应:-

ffmpeg version N-94112-gbb11584924 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.1.1 (GCC) 20190621

  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt

  libavutil      56. 29.100 / 56. 29.100

  libavcodec     58. 53.100 / 58. 53.100

  libavformat    58. 28.100 / 58. 28.100

  libavdevice    58.  7.100 / 58.  7.100

  libavfilter     7. 55.100 /  7. 55.100

  libswscale      5.  4.101 /  5.  4.101

  libswresample   3.  4.100 /  3.  4.100

  libpostproc    55.  4.100 / 55.  4.100

[dshow @ 0000016c508c8dc0] DirectShow video device options (from video devices)

[dshow @ 0000016c508c8dc0]  Pin "Capture" (alternative pin name "0")

[dshow @ 0000016c508c8dc0]   vcodec=h264  min s=1920x1080 fps=30 max s=1920x1080 fps=60.0002

[dshow @ 0000016c508c8dc0]   vcodec=h264  min s=1920x1080 fps=30 max s=1920x1080 fps=60.0002

[dshow @ 0000016c508c8dc0]   vcodec=h264  min s=1280x720 fps=30 max s=1280x720 fps=60.0002

[dshow @ 0000016c508c8dc0]   vcodec=h264  min s=1280x720 fps=30 max s=1280x720 fps=60.0002

[dshow @ 0000016c508c8dc0]   vcodec=h264  min s=640x360 fps=30 max s=640x360 fps=60.0002

[dshow @ 0000016c508c8dc0]   vcodec=h264  min s=640x360 fps=30 max s=640x360 fps=60.0002

[dshow @ 0000016c508c8dc0]   vcodec=h264  min s=1280x960 fps=30 max s=1280x960 fps=60.0002

[dshow @ 0000016c508c8dc0]   vcodec=h264  min s=1280x960 fps=30 max s=1280x960 fps=60.0002

[dshow @ 0000016c508c8dc0]   vcodec=h264  min s=1024x768 fps=30 max s=1024x768 fps=60.0002

[dshow @ 0000016c508c8dc0]   vcodec=h264  min s=1024x768 fps=30 max s=1024x768 fps=60.0002

[dshow @ 0000016c508c8dc0]   vcodec=h264  min s=640x480 fps=30 max s=640x480 fps=60.0002

[dshow @ 0000016c508c8dc0]   vcodec=h264  min s=640x480 fps=30 max s=640x480 fps=60.0002

[dshow @ 0000016c508c8dc0]   vcodec=h264  min s=1280x1024 fps=30 max s=1280x1024 fps=60.0002

[dshow @ 0000016c508c8dc0]   vcodec=h264  min s=1280x1024 fps=30 max s=1280x1024 fps=60.0002

[dshow @ 0000016c508c8dc0]   vcodec=h264  min s=1280x800 fps=30 max s=1280x800 fps=60.0002

[dshow @ 0000016c508c8dc0]   vcodec=h264  min s=1280x800 fps=30 max s=1280x800 fps=60.0002

[dshow @ 0000016c508c8dc0]   vcodec=mjpeg  min s=1920x1080 fps=15 max s=1920x1080 fps=30

[dshow @ 0000016c508c8dc0]   vcodec=mjpeg  min s=1920x1080 fps=15 max s=1920x1080 fps=30

[dshow @ 0000016c508c8dc0]   vcodec=mjpeg  min s=1280x720 fps=15 max s=1280x720 fps=30

[dshow @ 0000016c508c8dc0]   vcodec=mjpeg  min s=1280x720 fps=15 max s=1280x720 fps=30

[dshow @ 0000016c508c8dc0]   vcodec=mjpeg  min s=640x360 fps=15 max s=640x360 fps=30

[dshow @ 0000016c508c8dc0]   vcodec=mjpeg  min s=640x360 fps=15 max s=640x360 fps=30

[dshow @ 0000016c508c8dc0]   vcodec=mjpeg  min s=1280x960 fps=15 max s=1280x960 fps=30

[dshow @ 0000016c508c8dc0]   vcodec=mjpeg  min s=1280x960 fps=15 max s=1280x960 fps=30

[dshow @ 0000016c508c8dc0]   vcodec=mjpeg  min s=1024x768 fps=15 max s=1024x768 fps=30

[dshow @ 0000016c508c8dc0]   vcodec=mjpeg  min s=1024x768 fps=15 max s=1024x768 fps=30

[dshow @ 0000016c508c8dc0]   vcodec=mjpeg  min s=640x480 fps=15 max s=640x480 fps=30

[dshow @ 0000016c508c8dc0]   vcodec=mjpeg  min s=640x480 fps=15 max s=640x480 fps=30

[dshow @ 0000016c508c8dc0]   vcodec=mjpeg  min s=1280x1024 fps=15 max s=1280x1024 fps=30

[dshow @ 0000016c508c8dc0]   vcodec=mjpeg  min s=1280x1024 fps=15 max s=1280x1024 fps=30

[dshow @ 0000016c508c8dc0]   vcodec=mjpeg  min s=1280x800 fps=15 max s=1280x800 fps=30

[dshow @ 0000016c508c8dc0]   vcodec=mjpeg  min s=1280x800 fps=15 max s=1280x800 fps=30

[dshow @ 0000016c508c8dc0]   pixel_format=yuyv422  min s=640x480 fps=15 max s=640x480 fps=30

[dshow @ 0000016c508c8dc0]   pixel_format=yuyv422  min s=640x480 fps=15 max s=640x480 fps=30

[dshow @ 0000016c508c8dc0]   pixel_format=yuyv422  min s=640x360 fps=15 max s=640x360 fps=30

[dshow @ 0000016c508c8dc0]   pixel_format=yuyv422  min s=640x360 fps=15 max s=640x360 fps=30

[dshow @ 0000016c508c8dc0]   pixel_format=yuyv422  min s=320x240 fps=15 max s=320x240 fps=30

[dshow @ 0000016c508c8dc0]   pixel_format=yuyv422  min s=320x240 fps=15 max s=320x240 fps=30

[dshow @ 0000016c508c8dc0]   pixel_format=yuyv422  min s=320x180 fps=15 max s=320x180 fps=30

[dshow @ 0000016c508c8dc0]   pixel_format=yuyv422  min s=320x180 fps=15 max s=320x180 fps=30

标签: electronusbvideo-streamingresolution

解决方案


推荐阅读