Search code examples
ffmpegcameragstreamerorange-pi

Cannot duplicate virtual camera on Orange Pi 5B


I have faced with the issue that I cannot duplicate virtual camera for SkyDroid 5.8GHz OTG Receiver on Orange Pi 5B:

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 ...

Also I tried to duplicate video camera using 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

But it also did not work ...

The reason I want it, because I try to have additional processing using OpenCV but the camera is opened by another application, and it is not possible to similtuniuously open camera in 2 applications at the same time ...

Have somebody faced with similar issue ?


Solution

  • For me helped the following answer: https://unix.stackexchange.com/a/343837

    I was able successfully create virtual camera using:

    sudo modprobe v4l2loopback devices=1
    ffmpeg -f video4linux2 -i /dev/video0 -codec copy -f v4l2 /dev/video2
    

    In my case /dev/video1 was already exists that is why I used /dev/video2