ammen99 / wf-recorder

MIT License
861 stars 63 forks source link

Error: v4l2loopback does not work #112

Closed hissssst closed 1 year ago

hissssst commented 4 years ago

Description

wf-recorder started with specific options (as described in #43) should record screen output to /dev/video2

Steps to reproduce

  1. Install required dependencies (which are described in #43)
  2. Check loopback with $ v4l2-ctl --list-devices
  3. Run wf-recorder
    $ wf-recorder --muxer=v4l2 --codec=rawvideo --file=/dev/video2
    selected region 0 0 0 0
    Choosing pixel format bgr0
    Output #0, video4linux2,v4l2, to '/dev/video2':
    Stream #0:0: Unknown: none (rawvideo)
    [video4linux2,v4l2 @ 0x7ff998000d00] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
  4. Check video on /dev/video2
    $ cat /dev/video2 | pv
    0.00 B 0:00:03 [0.00 B/s] [<=>

    Even ffplay /dev/video2 shows nothing

soreau commented 4 years ago

The wiki says to use -x yuv420p. Are you doing this?

hissssst commented 4 years ago

43 sais this option is optional. Anyway, it doesn't work with this option either. I am ready to provide some debug and versions info, just tell me which ones

soreau commented 4 years ago

You might need to install the latest version of the v4l2loopback module.

hissssst commented 4 years ago

I have v4l2loopback installed and probed. v4l2-ctl shows /dev/video2

hissssst commented 4 years ago

@ammen99 ping

ammen99 commented 4 years ago

@hissssst I do not know how to help you. As far as I know, v4l2loopback works on my machine, and on many others, so this could be just a problem in your setup.

The only difference between your command and mine is that I am running with wf-recorder --muxer=v4l2 --codec=rawvideo --pixel-format=yuv420p --file=/dev/video2 (note the pixel format option).

hissssst commented 4 years ago

@ammen99 Ok, I won't close this issue just in case if someone experienced with v4l2 comes by... I am ready to provide all diagnostic info and stuff

soreau commented 4 years ago

To reiterate, if you haven't already, my suggestion is to build latest v4l2loopback module from git and load the .ko with insmod. You don't have to install it globally. I can say this fixed the situation at least once for me in the past.

roosemberth commented 4 years ago

I got v4l2loopback working with the following command: wf-recorder --muxer=v4l2 -f /dev/video4 -c rawvideo -x yuyv422. I just need to figure how to mirror (or rather unmirror) the image :( (edit: image is not mirrored in the other side.)

WhyNotHugo commented 3 years ago

I was having the same error as op:

$ wf-recorder --muxer=v4l2 -f /dev/video2 -c rawvideo -x yuyv422
Output file "/dev/video2" exists. Overwrite? Y/n: y
Please select an output from the list to capture (enter output no.):
1. Name: eDP-1 Description: Chimei Innolux Corporation 0x14D4 0x00000000 (eDP-1)
2. Name: HDMI-A-2 Description: Ancor Communications Inc ROG PG348Q K8LMQS109773 (HDMI-A-2)
Enter output no.:1
selected region 0 0 0 0
Choosing pixel format yuyv422
Output #0, video4linux2,v4l2, to '/dev/video2':
    Stream #0:0: Unknown: none (rawvideo)
[video4linux2,v4l2 @ 0x7f320c000d00] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
[video4linux2,v4l2 @ 0x7f320c000d00] ioctl(VIDIOC_G_FMT): Invalid argument
Failed to write file header
Invalid argument

I got v4l2loopback working with the following command: wf-recorder --muxer=v4l2 -f /dev/video4 -c rawvideo -x yuyv422

This works for me. Turns out I was pointing to /dev/video2, but that was the actual webcam. Not sure what /dev/video3 is, but video4 is the v4l2loopback one.

@hissssst Can you check what /dev/video* devices you have?

hissssst commented 3 years ago

@WhyNotHugo I have /dev/video0 and /dev/video1 /dev/video0 is my webcam while /dev/video1 shows

$ mpv /dev/video1
[ffmpeg/demuxer] video4linux2,v4l2: ioctl(VIDIOC_G_INPUT): Inappropriate ioctl for device
[lavf] avformat_open_input() failed
[ffmpeg/demuxer] video4linux2,v4l2: ioctl(VIDIOC_G_INPUT): Inappropriate ioctl for device
[lavf] avformat_open_input() failed
Failed to recognize file format.

Exiting... (Errors when loading file)

I've tried starting wf-recorder at /dev/video1 and it fails as you've described in your comment. And at /dev/video2

$ wf-recorder --muxer=v4l2 -f /dev/video2 -c rawvideo -x yuyv422
selected region 0 0 0 0
Choosing pixel format yuyv422
Output #0, video4linux2,v4l2, to '/dev/video2':
    Stream #0:0: Unknown: none (rawvideo)
avio_open failed
Figuera commented 3 years ago

Although the recording work for me, meaning that I can watch it using ffplay. I can't use it as a webcam in Zoom, it shows as blank. I am using --pixel-format=yuv420p. Anything else I could try? Maybe some debuging tests.

telamon commented 3 years ago

Hey! So let me just say thanks to everyone for the info above, I got the playback successfully working in VLC though I would like to be able to share my screen via electron apps (at least as a dummy-webcam) for work.

So I did some digging and from what I can tell from discord's log-output the main complaint is:

[299:264] [97] (webrtcvideocapturer.cc:179): Failed to find usable formats for id: platform:v4l2loopback-000

Tracing that to chromium source I can see that it's trying to enumerate the capabilities of the loop-back device in an attempt to discover what format the stream is available in.

So i turned to the utility v4l2loopback-ctl that came with the dkms module, it has this nifty hack to force set capabilities for a stream that I hoped would be picked up by electron's enumerator.

v4l2loopback-ctl set-caps "video/x-raw, format=YUY2, width=2560, height=1440" /dev/video4

Sadly I did not get the expected results, discord still shows the log-line and a black screen. Here's my "workspace" script in case anyone could help me me solve the issue: sharescreen.sh

hissssst commented 1 year ago

Over the years, I am not experiencing the problem anymore, since it got fixed and I've missed it somehow. Thanks, @ammen99