Dummy video device - v4l2loopback - webRTC
Asked Answered
B

3

6

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.

Beneficent answered 26/5, 2014 at 21:14 Comment(1)
For me, v4l2-loopback cameras do not work in Firefox (devices show up but error), but works on Chrome. Maybe the same problem here.Papert
C
6

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

Custard answered 4/6, 2014 at 9:6 Comment(0)
N
3

I was able to get this to work using ffmpeg. This was the command I used:

ffmpeg -re -f lavfi -i "movie=my_video_file.mp4" -f v4l2 /dev/video0

After doing that, I was able to access this virtual webcam, which was looping a video file infinitely, from my WebRTC app.

Nereid answered 28/1, 2016 at 18:36 Comment(0)
P
0

not sure if this will help or not but you could try using webcamstudio - it creates a loopback device also and can do the source mixing as well - as i remember it uses ffmpeg as its backend so you should be able to tweak it into any format you like

Prosimian answered 27/5, 2014 at 4:5 Comment(7)
Hi man, thank you for suggestion but i have already tried with webcamstudio ( v0.61 manual compiled and v0.54 precompiled) and i have encountered a lot of problems: missing class, exception, no dev/video in output..Beneficent
i think the issue is most likely not related to vLine - the more likely point of failure is in the loopback driver that provides the source and your browser that actually decodes the stream - i would try another browser - try your current setup on other sites like jtv that use a flash client and see if you can get any output from these to be sure that it is not only failing with webRTC or vLine - you may find your current setup doesnt work anywhere - and youd probably get further by asking the V4l2loopback or browser peeps about thisProsimian
this is the way that i have followed: xawtv work, flashplayer work and i have done a basic script for test the first steps to make a video view and don't work with the major browser ( firefox 28 and google chrome 35 )Beneficent
if you are referring to flash media encoder that was not my suggestion - i was suggesting you got to a website like justin.tv or ustream and trying to broadcast there using their flash-based browser plugin just to see if your browser can access your device at all - if it can not then try firefox also - if you can not broadcast on jtv then it is not a webRTC or vLine issueProsimian
my previous test is referred to this: testwebcam.com is not the same of ustream? anyway work good with both..Beneficent
im no expert here btw just offering diagnostic suggestions - at this point its down to isolating the actual point of failure - the next thing i would try is to bypass the loopback device and try to access a webcam directly to be sure that your vLine app is able to access any video source at all - and i would also try bypassing vLine by testing with raw webRTC demo script or the webrtc live demo - if your setup does not work with any webRTC based app then vLine is probably not the problem and you could then ask the webRTC folks about thisProsimian
I have found a solution with using gst-launch: "gst-launch-1.0 videotestsrc ! v4l2sink device=/dev/video0" . The test video now work correctly! Thank you man for help!Beneficent

© 2022 - 2024 — McMap. All rights reserved.