Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebRTC videotestsrc freezes with gst-launch-1.0 but not with gst-launch-0.10 #251

Open
wehlutyk opened this issue Jan 30, 2020 · 8 comments

Comments

@wehlutyk
Copy link

First of all, thanks for the great module! Lots of fun stuff can be done with this. Now I've been all over SO and the issues here, to no avail with this.

Environment

  • v4l2loopback version: 0.12.3
  • kernel version: Linux keon 4.19.99-1-lts #1 SMP Mon, 27 Jan 2020 21:30:28 +0000 x86_64 GNU/Linux
  • Distribution (+version):
    LSB Version:	1.4
    Distributor ID:	Arch
    Description:	Arch Linux
    Release:	rolling
    Codename:	n/a
    

Problem

Ultimately, I want to feed GStreamer's videotestsrc to a WebRTC conference (videotestsrc for now, and ultimately an incoming RTMP stream).

To test using videotestsrc as a webcam in the browser, I run:

sudo modprobe v4l2loopback exclusive_caps=1
gst-launch-1.0 videotestsrc ! v4l2sink device=/dev/video2  # with or without identity drop-allocation=1, if there is an error

Then I open the following webpage:

<!doctype html>
<html>
  <head>
    <title>WebRTC video test</title>
    <meta charset='utf-8'>
  </head>
  <body>
    <div class="contentarea">
      <video id="video">Video stream not available.</video>
    </div>
    <script>
      navigator.mediaDevices.getUserMedia({video: true})
      .then(function(mediaStream) {
        var video = document.querySelector('video');
        video.srcObject = mediaStream;
        video.onloadedmetadata = function(e) {
          video.play();
        };
      })
      .catch(function(err) { console.log(err.name + ": " + err.message); });
    </script>
  </body>
</html>

In the browser, the v4l2loopback device appears as an option for webcams, so I select it.

Observed Results

A single video frame is shown (the test pattern) after which the video freezes. I expect the video to run.

If instead I use gst-launch-0.10 videotestsrc ! v4l2sink device=/dev/video2 (so GStreamer 0.10), the video plays in the browser.

Relevant logs

In case the caps used are useful:

gst-launch-1.0 -v videotestsrc ! v4l2sink device=/dev/video2
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0.GstPad:src: caps = video/x-raw, format=(string)YUY2, width=(int)320, height=(int)240, framerate=(fraction)30/1, multiview-mode=(string)mono, interlace-mode=(string)progressive, colorimetry=(string)2:4:7:1, pixel-aspect-ratio=(fraction)1/1
/GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0.GstPad:sink: caps = video/x-raw, format=(string)YUY2, width=(int)320, height=(int)240, framerate=(fraction)30/1, multiview-mode=(string)mono, interlace-mode=(string)progressive, colorimetry=(string)2:4:7:1, pixel-aspect-ratio=(fraction)1/1
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
$ gst-launch-0.10 -v videotestsrc ! v4l2sink device=/dev/video2
Setting pipeline to PAUSED ...
/GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0.GstPad:src: caps = video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, color-matrix=(string)sdtv, chroma-site=(string)mpeg2
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0: queue-size = 8
/GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0.GstPad:sink: caps = video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, color-matrix=(string)sdtv, chroma-site=(string)mpeg2
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
@umlaeute
Copy link
Owner

did you try setting max_buffers=2? (i'm thinking of making this the default)

@umlaeute
Copy link
Owner

which browsers did you try?
while i get occasional blocks with firefox, chromium (chrome) doesn't seem to have this problem.

@wehlutyk
Copy link
Author

So

$ sudo modprobe v4l2loopback exclusive_caps=1 max_buffers=2
$ gst-launch-1.0 -v videotestsrc ! v4l2sink device=/dev/video2

Same behaviour.

I tested Firefox, and the device doesn't show up in Chromium (looks like the Chromium bug linked to in #78).

Surprisingly, it does show up in jitsi-meet which is an Electron app, and the video preview shows a running videotestsrc in the source-selection modal dialog, but after validating the app goes back to the physical webcam source (after sometimes showing a single frame from videotestsrc).

@umlaeute
Copy link
Owner

just to be sure: you did unload the v4l2loopback module before running modprobe again?

@wehlutyk
Copy link
Author

wehlutyk commented Jan 30, 2020

Yes I did

$ sudo modprobe -r v4l2loopback              
[sudo] password for sl: 
$ sudo modprobe v4l2loopback exclusive_caps=1 max_buffers=2
$ gst-launch-1.0 -v videotestsrc ! v4l2sink device=/dev/video2
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0.GstPad:src: caps = video/x-raw, format=(string)YUY2, width=(int)320, height=(int)240, framerate=(fraction)30/1, multiview-mode=(string)mono, interlace-mode=(string)progressive, colorimetry=(string)2:4:7:1, pixel-aspect-ratio=(fraction)1/1
/GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0.GstPad:sink: caps = video/x-raw, format=(string)YUY2, width=(int)320, height=(int)240, framerate=(fraction)30/1, multiview-mode=(string)mono, interlace-mode=(string)progressive, colorimetry=(string)2:4:7:1, pixel-aspect-ratio=(fraction)1/1
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock

# This is when I try Firefox

^Chandling interrupt.
Interrupt: Stopping pipeline ...
Execution ended after 0:00:18.079773332
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

Edit: add logs

Edit 2: (I get that you check for this!)

@wehlutyk
Copy link
Author

wehlutyk commented Jan 30, 2020

I should add that in both cases (GStreamer 0.10 and 1.0) VLC can read the capture device and the video plays (so it's only when reading it in Firefox that I see this behaviour). Could VLC help me debug this?


Edit: phrasing

@Wallacy
Copy link

Wallacy commented Feb 7, 2020

did you try setting max_buffers=2? (i'm thinking of making this the default)

Not related to this thread but max_buffers=2 solved some issues on my pipeline. Also, will be nice to make MAX_DEVICES configurable too.

@f8ith
Copy link

f8ith commented Feb 11, 2020

I also have this issue

did you try setting max_buffers=2? (i'm thinking of making this the default)

I also loaded the module with max_buffers=2 to no avail.
The specific command I ran is this: "sudo modprobe v4l2loopback exclusive_caps=1 devices=1 max_buffers=2"
The device works perfectly in Brave (Chromium derivative) but freezes in Firefox.

umlaeute added a commit that referenced this issue Mar 16, 2020
Related: #166
Related: #251
Related: #261

and probably others...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants