我遇到的问题是无法在 Orange Pi 5B 上为 SkyDroid 5.8GHz OTG 接收器复制虚拟摄像头:
orangepi@orangepi-desktop:~$ gst-launch-1.0 v4l2src device=/dev/video0 ! xvimagesink device=/dev/video2
Setting pipeline to PAUSED ...
ERROR: from element /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0: Could not initialise Xv output
Additional debug info:
../sys/xvimage/xvimagesink.c(1806): gst_xv_image_sink_open (): /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0:
Could not open display (null)
ERROR: pipeline doesn't want to preroll.
Failed to set pipeline to PAUSED.
Setting pipeline to NULL ...
Freeing pipeline ...
orangepi@orangepi-desktop:~$ gst-launch-1.0 v4l2src device=/dev/video0 ! v4l2sink device=/dev/video2
Setting pipeline to PAUSED ...
ERROR: from element /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0: Cannot identify device '/dev/video2'.
Additional debug info:
../sys/v4l2/v4l2_calls.c(608): gst_v4l2_open (): /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0:
system error: No such file or directory
ERROR: pipeline doesn't want to preroll.
Failed to set pipeline to PAUSED.
Setting pipeline to NULL ...
Freeing pipeline ...
我还尝试使用以下方法复制摄像机ffmpeg
:
orangepi@orangepi-desktop:~$ sudo ffmpeg -f video4linux2 -i /dev/video0 -codec copy -f v4l2 /dev/video2
ffmpeg version 6.0-5+git230804.e243e8d001~j1 Copyright (c) 2000-2023 the FFmpeg developers
built with gcc 11 (Ubuntu 11.4.0-1ubuntu1~22.04)
configuration: --prefix=/usr --extra-version='5+git230804.e243e8d001~j1' --toolchain=hardened --libdir=/usr/lib/aarch64-linux-gnu --incdir=/usr/include/aarch64-linux-gnu --arch=arm64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-version3 --enable-rkmpp --enable-sdl2 --disable-sndio --enable-pocketsphinx --enable-librsvg --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-shared
libavutil 58. 2.100 / 58. 2.100
libavcodec 60. 3.100 / 60. 3.100
libavformat 60. 3.100 / 60. 3.100
libavdevice 60. 1.100 / 60. 1.100
libavfilter 9. 3.100 / 9. 3.100
libswscale 7. 1.100 / 7. 1.100
libswresample 4. 10.100 / 4. 10.100
libpostproc 57. 1.100 / 57. 1.100
[mjpeg @ 0xaaab04104190] EOI missing, emulating
Input #0, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 3317.330868, bitrate: N/A
Stream #0:0: Video: mjpeg (Baseline), yuvj422p(pc, bt470bg/unknown/unknown), 640x480, 30 fps, 30 tbr, 1000k tbn
[video4linux2,v4l2 @ 0xaaab04105750] Unable to open V4L2 device '/dev/video2'
[out#0/video4linux2,v4l2 @ 0xaaab040b9200] Could not write header (incorrect codec parameters ?): No such file or directory
[vost#0:0/copy @ 0xaaab04107640] Error initializing output stream:
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Last message repeated 1 times
[video4linux2,v4l2 @ 0xaaab041039d0] Some buffers are still owned by the caller on close.
ioctl(VIDIOC_QBUF): Bad file descriptor
但它也没有起作用......
我想要它的原因是,因为我尝试使用 OpenCV 进行额外处理,但相机是由另一个应用程序打开的,并且不可能同时在 2 个应用程序中打开相机...
有人遇到过类似的问题吗?
答案1
对于我来说以下答案很有帮助: https://unix.stackexchange.com/a/343837
我能够使用以下方法成功创建虚拟相机:
sudo modprobe v4l2loopback devices=1
ffmpeg -f video4linux2 -i /dev/video0 -codec copy -f v4l2 /dev/video2
就我而言/dev/video1
已经存在了,这就是为什么我使用/dev/video2