5

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.

4

3 回答 3

5

有两件事:

  • 你需要一个足够新的v4l2loopback模块,IIRC 你必须至少使用 0.7.1

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

  • 如果某些(其他)应用程序正在向它写入视频数据,则v4l2loopback-device 只会显示为正确的网络摄像头。例如

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

于 2014-06-04T09:06:19.030 回答
3

我能够使用 ffmpeg 让它工作。这是我使用的命令:

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

之后,我可以从我的 WebRTC 应用程序访问这个无限循环视频文件的虚拟网络摄像头。

于 2016-01-28T18:36:16.677 回答
0

不确定这是否有帮助,但您可以尝试使用 webcamstudio - 它还创建一个环回设备,并且还可以进行源混合 - 我记得它使用 ffmpeg 作为其后端,因此您应该能够将其调整为任何格式你喜欢

于 2014-05-27T04:05:07.583 回答