Search code examples
opencvstreamvideo-streamingwebcamlinphone

Clone WebCam stream in mediastreamer2


I'm using mediastreamer2 for a video stream from a Webcam, via a RTP connection to another System.

I want to have 2 (or more) outgoing video streams, the first one initialized works fine, but the second stream is complaining, that the WebCam is busy.

libv4l2: error setting pixformat: Device or resource busy

Do you have any hints, and/or ideas how to clone the webcam video stream or another way to implement 2 videostreams?

thanks in advance! Mediastreamer2 is written in c , I'm using Ubuntu and Qt to code.

regards


Solution

  • Ok I have a solution :

    1. Loopback is a nice packet to make virtual Webcams.

      sudo apt-get install v4l2loopback-dkms //to install
      sudo modprobe v4l2loopback devices=X // X = number of virtual cams

    2. Copy Videosource from Real Webcam to Virtual ( check this page )

      ffmpeg -f video4linux2 -s 352x288 -i /dev/video0 -codec copy -f v4l2 /dev/video1 -codec copy -f v4l2 /dev/video2 // this copys from video0 to the VirtualCams video1

    3. Start Streams by selecting Virtual Cams

      MSWebCam *cam = ms_web_cam_manager_get_cam(m,"V4L2: /dev/video1");