Dummy video device - v4l2loopback - webRTC

Al3 picture Al3 · May 26, 2014 · Viewed 12.6k times · Source

I need to play multiple video for test a video server. I'm using lubuntu 14.04 and have installed V4l2loopback to make the device file ( /dev/videoN )

I am using mplayer to play video from this device as described mplayer cam

I have done the modify to the source code and successfully played the video and viewed with xawtv and with flashplayer (on firefox 28). I have tried to view with webRtc but it can't work.

Do you have some idea to do this? There is some particular pixelformat to define in examples/yuv4mpeg_to_v4l2.c ?

.....

I'm trying to find the problem using direct access to the resource with this script:

<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">

    <title>Test rtc</title>
    <script type="text/javascript" charset="utf-8">

    navigator.getUserMedia = 
    ( 
        navigator.getUserMedia ||
        navigator.webkitGetUserMedia ||
        navigator.mozGetUserMedia ||
        navigator.msGetUserMedia
    );

    var constraints = 
    {
        audio: true,
        video:true,
        video: 
        {               
            mandatory: 
            {
              minWidth: 640,
              minHeight: 360
            }
        }
    };

    if( navigator.getUserMedia ) 
    {
        navigator.getUserMedia(

            // constraints
            constraints ,

            // successCallback
            function(localMediaStream) 
            {

                var video = document.querySelector('video');
                video.src = window.URL.createObjectURL(localMediaStream);

                video.play();

                console.log( video );
                console.log( localMediaStream );
            },

            // errorCallback
            function(err) 
            {
                console.log("The following error occured: " + err);
            }
        );
    } 
    else 
    {
        console.log("getUserMedia not supported");
    }

    </script>

</head> 
<body>
    <video>   
</body> 
</html>

The video constraingts are take from mplayer output:

VIDEO:  640x360  25.000 fps  555.0 kbps (69.4 kB/s)
[swscaler @ 0x7f83633f3640]BICUBIC scaler, from yuv420p to yuv420p using MMXEXT
VO: [yuv4mpeg] 480x360 => 640x360 Planar YV12 

But the problem persists: "The following error occured: Starting video failed"..

The video is correctly played and visible both with xawtv and with flashplayer.

Answer

uml&#228;ute picture umläute · Jun 4, 2014

there are two things:

  • you need a recent enough v4l2loopback module, IIRC you have to use at least 0.7.1

    $ dmesg | grep v4l2loopback
    [0000123.456] v4l2loopback driver version 0.8.0 loaded

  • the v4l2loopback-device will only appear as a proper webcam, if some (other) application is writing video data to it. e.g.

    gst-launch videotestsrc ! v4l2sink device=/dev/video0