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

Requested output format 'v4l2' is not a suitable output format #92

Closed
pshanoop opened this issue Apr 30, 2020 · 23 comments
Closed

Requested output format 'v4l2' is not a suitable output format #92

pshanoop opened this issue Apr 30, 2020 · 23 comments

Comments

@pshanoop
Copy link

When run wf-recorder --muxer=v4l2 --codec=rawvideo --file=/dev/video2 -o eDP-1
I get output

selected region 0 0 0 0
[NULL @ 0x7f54bc000cc0] Requested output format 'v4l2' is not a suitable output format
Failed to allocate output context

User has video group and v4l2loopback module is loaded.

Version: 0.2.1
OS: Debian sid

Btw, Thanks for developing this tool. Except this issue it's working pretty nice :)

@soreau
Copy link
Collaborator

soreau commented May 1, 2020

You might check the output of ffmpeg -formats | grep -i v4l2 and make sure it shows v4l2 listed in the supported formats list. If not, you might need ffmpeg built with v4l2 support.

@pshanoop
Copy link
Author

pshanoop commented May 1, 2020

You might check the output of ffmpeg -formats | grep -i v4l2 and make sure it shows v4l2 listed in the supported formats list. If not, you might need ffmpeg built with v4l2 support.

Thanks for the response


ffmpeg version 4.2.2-1+b1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9 (Debian 9.2.1-28)
  configuration: --prefix=/usr --extra-version=1+b1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
 DE video4linux2,v4l2 Video4Linux2 output device

@soreau
Copy link
Collaborator

soreau commented May 1, 2020

Here I see

 E v4l2            Video4Linux2 output device
 D  video4linux2,v4l2 Video4Linux2 device grab

@pshanoop
Copy link
Author

pshanoop commented May 1, 2020

Something like that working (Off course blank screen due to x11grab)

ffmpeg -f x11grab -r 30 -s 2560x1440 -i :0.0+1920,0 -vcodec rawvideo -pix_fmt yuv420p -threads 16 -f v4l2 /dev/video4

This means Muxer exists right ?

@soreau
Copy link
Collaborator

soreau commented May 1, 2020

You probably need ffmpeg built with --enable-indev=v4l2

@pshanoop
Copy link
Author

pshanoop commented May 1, 2020

Hi,

Recompiled it with --enable-indev=v4l2

ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9 (Debian 9.3.0-11)
  configuration: --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --enable-indev=v4l2

Still same :'(

@soreau
Copy link
Collaborator

soreau commented May 1, 2020

Did you install the libv4l development package before configuring ffmpeg and check the configure output for enabled v4l2 components?

@soreau
Copy link
Collaborator

soreau commented May 1, 2020

You might try adding --enable-muxer=v4l2 as well.

@soreau
Copy link
Collaborator

soreau commented May 1, 2020

but there must be some dependency problem because this is the ffmpeg configuration I use, and v4l2 loopback works: https://pastebin.com/raw/MfGday27

@pshanoop
Copy link
Author

pshanoop commented May 2, 2020

Did you install the libv4l development package before configuring ffmpeg and check the configure output for enabled v4l2 components?

Yes, libv4l2-dev is installed.

You might try adding --enable-muxer=v4l2 as well.

I tried but this config doesn't exists.

There is my configuration output. It also shows indev v4l2
https://pastebin.com/Z4nhEgqe

May be the ffmpeg has some bug, Which version are you using ? Or Do you if there is any other way to test v4l2 working ?, I have no clue how ffmpeg works.

@soreau
Copy link
Collaborator

soreau commented May 2, 2020

I'm using the git master version from https://github.com/FFmpeg/FFmpeg

@pshanoop
Copy link
Author

pshanoop commented May 2, 2020

I compiled many different possibilities (diff branches, config) . None worked. :'(

I will try in a fresh installation Debian sid on kvm. I don't know any other way to figure out this issue.

@soreau
Copy link
Collaborator

soreau commented May 2, 2020

Well sorry I couldn't help, I don't know what the exact problem is but apparently it's with ffmpeg configuration most likely. There is an off chance that there's something wrong with the kernel module you have, if you want to try building that it's here. To test it without installing, run make and then sudo rmmod v4l2loopback and sudo insmod v4l2loopback.ko.

@pshanoop
Copy link
Author

pshanoop commented May 2, 2020

Btw, I tried ffmpeg -i /dev/video0 -pix_fmt yuv420p -s 1024x768 -f v4l2 /dev/video4
here video0 webcam. This is working fine. Isn't wf-recorder doing same ? Just trying to understand the working.

@soreau
Copy link
Collaborator

soreau commented May 2, 2020

What happens if you try /dev/video2 (which should be created by loading the kernel module)?

@soreau
Copy link
Collaborator

soreau commented May 2, 2020

I see you're using /dev/video4 here but in the original command you used /dev/video2

@pshanoop
Copy link
Author

pshanoop commented May 3, 2020

I see you're using /dev/video4 here but in the original command you used /dev/video2

/dev/video4 is my loopback camera. On top I mis-copied.

@soreau
Copy link
Collaborator

soreau commented May 21, 2020

@EvanCarroll This could indicate the module is not compatible with your kernel. Check dmesg for messages.

@EvanCarroll
Copy link

I'm having the same problem as @pshanoop with Debian testing. Did you get this working?

@pshanoop
Copy link
Author

pshanoop commented Jun 11, 2020 via email

@EvanCarroll
Copy link

EvanCarroll commented Jun 11, 2020

i'll spend some time and try to gather more information here.

wl_display_dispatch(0x55571a185000, 0, 0, 0x55571a147010)                                                              = 3
memcpy(0x7ffde8872050, "/dev/video2", 11)                                                                              = 0x7ffde8872050
memcpy(0x7ffde8872080, "rawvideo", 8)                                                                                  = 0x7ffde8872080
memcpy(0x7ffde88720a0, "v4l2", 4)                                                                                      = 0x7ffde88720a0
_Znwm(272, 0x7ffde8872208, 0xffffffff00000000, 0)                                                                      = 0x55571a18a7d0
_ZNSt6thread15_M_start_threadESt10unique_ptrINS_6_StateESt14default_deleteIS1_EEPFvvE(0x7ffde8871ed8, 0x7ffde8871ef0, 0x7f6d84a32200, 0x55571a18a890) = 0
wl_proxy_marshal(0x55571a18ae90, 1, 0, 0x4cecc549b)                                                                    = 0
wl_proxy_destroy(0x55571a18ae90, 0, 0, 0x55571a147010)                                                                 = 0
wl_proxy_marshal_constructor(0x55571a189c30, 0, 0x555719da4600, 0)                                                     = 0x55571a18ae90
wl_proxy_add_listener(0x55571a18ae90, 0x555719da4420, 0, 0)                                                            = 0
wl_display_dispatch(0x55571a185000, 0x555719da4420, 0, 0 <unfinished ...>
mkstemp64(0x7ffde8871a10, 0x55571a18ae90, 0, 1920)                                                                     = 4
ftruncate64(4, 0x7e9000, 194, 2)                                                                                       = 0
unlink("/tmp/wf-recorder-shared-cBWH4w")                                                                               = 0
mmap64(0, 0x7e9000, 3, 1)                                                                                              = 0x7f6d7b5f9000
wl_proxy_marshal_constructor(0x55571a18af30, 0, 0x555719da4840, 0[NULL @ 0x7f6d74000cc0] )                                                     = 0x55571a18a6e0
Requested output format 'v4l2' is not a suitable output format
v4l2-compliance SHA: not available, 64 bits

Compliance test for v4l2 loopback device /dev/video2:

Driver Info:
	Driver name      : v4l2 loopback
	Card type        : Dummy video device (0x0000)
	Bus info         : platform:v4l2loopback-000
	Driver version   : 5.6.14
	Capabilities     : 0x85208003
		Video Capture
		Video Output
		Video Memory-to-Memory
		Read/Write
		Streaming
		Extended Pix Format
		Device Capabilities
	Device Caps      : 0x05208003
		Video Capture
		Video Output
		Video Memory-to-Memory
		Read/Write
		Streaming
		Extended Pix Format

Required ioctls:
		fail: v4l2-compliance.cpp(665): (dcaps & input_caps) && (dcaps & output_caps)
	test VIDIOC_QUERYCAP: FAIL

Allow for multiple opens:
	test second /dev/video2 open: OK
		fail: v4l2-compliance.cpp(665): (dcaps & input_caps) && (dcaps & output_caps)
	test VIDIOC_QUERYCAP: FAIL
		fail: v4l2-compliance.cpp(735): prio != match
	test VIDIOC_G/S_PRIORITY: FAIL
		fail: v4l2-compliance.cpp(724): !ok
	test for unlimited opens: FAIL

Debug ioctls:
	test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
	test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
	test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
	test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
	test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
	test VIDIOC_ENUMAUDIO: OK (Not Supported)
	test VIDIOC_G/S/ENUMINPUT: OK
	test VIDIOC_G/S_AUDIO: OK (Not Supported)
	Inputs: 1 Audio Inputs: 0 Tuners: 0

Output ioctls:
	test VIDIOC_G/S_MODULATOR: OK (Not Supported)
	test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
	test VIDIOC_ENUMAUDOUT: OK (Not Supported)
	test VIDIOC_G/S/ENUMOUTPUT: OK
	test VIDIOC_G/S_AUDOUT: OK (Not Supported)
	Outputs: 1 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
	test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
	test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
	test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
	test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls (Input 0):
	test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
	test VIDIOC_QUERYCTRL: OK
	test VIDIOC_G/S_CTRL: OK
	test VIDIOC_G/S/TRY_EXT_CTRLS: OK
		fail: v4l2-test-controls.cpp(830): subscribe event for control 'User Controls' failed
	test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: FAIL
	test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
	Standard Controls: 1 Private Controls: 4

Format ioctls (Input 0):
		fail: v4l2-test-formats.cpp(311): Video Capture cap set, but no Video Capture formats defined
	test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: FAIL
		fail: v4l2-test-formats.cpp(1324): got error 22 when setting parms for buftype 1
	test VIDIOC_G/S_PARM: FAIL
	test VIDIOC_G_FBUF: OK (Not Supported)
		fail: v4l2-test-formats.cpp(605): Video Capture cap set, but no Video Capture formats defined
	test VIDIOC_G_FMT: FAIL
	test VIDIOC_TRY_FMT: OK (Not Supported)
	test VIDIOC_S_FMT: OK (Not Supported)
	test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
	test Cropping: OK (Not Supported)
	test Composing: OK (Not Supported)
		fail: v4l2-test-formats.cpp(1787): doioctl(node, VIDIOC_G_FMT, &fmt)
	test Scaling: FAIL

Codec ioctls (Input 0):
	test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
	test VIDIOC_G_ENC_INDEX: OK (Not Supported)
	test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls (Input 0):
	test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
	test VIDIOC_EXPBUF: OK (Not Supported)
	test Requests: OK (Not Supported)

Total for v4l2 loopback device /dev/video2: 44, Succeeded: 35, Failed: 9, Warnings: 0

wfleming added a commit to wfleming/dotfiles that referenced this issue Jun 15, 2020
I've spent some time this week setting up a new laptop, and as usual for
some reason I consider a new machine a great time to re-evaluate my
entire setup. One of the things I wanted to re-evaluate was my window
manager, and I wondered: "is Wayland good enough to use now?" The answer
turned out to be that it is so, so, close, and if it weren't for one
deal-breaker annoyance I would be all-in.

I started by looking at the current available tiling compositors for
Wayland. [Waymonad] is (unsurprisingly) the philisophical descendant of
Xmonad for Wayland, but from some light inspection it looks much less
mature to me than some of the alternatives, it hasn't attracted the same
kind of community that Xmonad has AFAICT, and although I'm happy to
spend some time learning a new tool, right now I have minimal interest
in figuring out a new window manager without docs or a community from
reading source code.

So the obvious choice seems to be [sway], which is mostly an [i3] clone
for Wayland, and as i3 is a reasonably close cousin to Xmonad in X11 (I
think it's the usual choice for people who want a tiling window manager
but don't want to write Haskell), so I decided to give it a shot.

So I took a stab at setting up sway, and it's really great! My only real
complaint is that I somewhat prefer Xmonad's approach to managing
windows with designated layouts to i3/sway's approach to managing
windows by splitting and moving containers. Xmonad's approach is
simpler, while i3's is both more complex but also more flexible. (To be
fair, Xmonad is more of a window manager framework than just a window
manager, so I'm sure there are people with much more flexible Xmonad
setups: mine is not much different from the out-of-the-box experience,
so that's what I'm talking about.) But I'm getting used to the new
approach, and it's growing on me.

On the plus side, the overall experience of "managing" a sway
environment is *much* nicer than needing to massage an X11 environment
into working order.  Display management is built-in and just works,
there's no need for extra tools like my [`msu` script][msu], or the
several ways I trigger it.  There's less mucking about with
`xorg.conf.d` configs to get inputs like trackpads behving sanely (so
far). Getting a decent status bar to play nicely with the window manager
was also much less futzing around. Applications pretty much all just
work. It feels responsive and just generally less flakey than X11.

Ah, but the deal-breaker. One area where Wayland is well behind X11 is
the development of protocols that applications can use for
screen-sharing. They exist, but AFAICT they're unevenly supported by
compositors and even more unevenly supported by applications. I spent an
afternoon trying various approaches, but for the life of me I could not
get Zoom to do anything like screen sharing of my sway desktop. And
unfortunately with everybody being entirely remote in the midst of a
pandemic, "sharing my screen on a Zoom call" is a non-negotiable
requirement for me several times a week right now.

But I like the advantages of sway enough that after a few days of
playing with it I am loathe to go back to my old setup, so this is the
awful compromise I've landed on for now: I've put together an i3/polybar
setup for X11 that is almost the same as my sway/waybar setup for
Wayland. And I'm going to try and use both: I'll start my day in an X
session on days when I expect to be on calls, but try to spend time in
Wayland if I don't expect to be be screen-sharing. Hopefully the
screen-sharing situation will improve and I can drop this crufty dual
setup and delete a bunch of X11 cruft from my dotfiles.

Wayland definitely seems like the future, I guess that future just isn't
quite here for those of us who prefer tiling window managers (and thus
don't want to use GNOME). In some ways it reminds me of Systemd: it
feels less "unixy" because it's not organized around very focused
programs that interact with each other, but instead tends towards a more
monolithic implementation of a bunch of related functionality. And it
has some definitely questionable technical details. But the lived
experience of *using it* is so much better than what came before that it
seems obvious that it's what should be focused on.

For my own future reference, here is what I played with to try and get
screensharing working on Sway:

- swaywm/sway#4358 & swaywm/sway#3282
  - `xdg-desktop-portal-wlr` is apparently supposed to add appropriate
  support for screensharing, but it didn't work for me. I didn't bother
  trying to use a patched FF, so I'm not surprised that didn't work.
  Some post I saw somewhere suggested that Zoom actually detects its on
  GNOME, so maybe it would work here if I forced it to think it's on
  GNOME? Didn't try that, should do that.
  - The slightly crazier suggestion there was to use a v4l2loopback
  device to record your desktop as a "webcam" and then just pick that as
  your video camera in zoom. Clever, but awkard and hacky. I also ran
  into errors with having `wf-recorder` record using v4l2. (I don't
  think ammen99/wf-recorder#92 was the issue,
  `ffmpeg` said the code was available, the error was a bit more like
  ammen99/wf-recorder#70 but the kernel module
  was also there and the device was available.)
- https://gitlab.com/jamedjo/gnome-dbus-emulation-wlr - saw this
  mentioned in one of the Sway issues linked above. It's a Ruby
  project that apparently presents dbus services that look like GNOME
  services to trick apps like Zoom into thinking their on GNOME? Again,
  didnt' work for me.
- swaywm/sway#5083 has the truly crazy idea of
  running zoom, etc. via x11docker, running a VNC server on your host,
  and then connecting the x11docker to your desktop via VNC and sharing
  that.  I did not do that, I think I prefer to just switch back to X11.

[Waymonad]: https://github.com/waymonad/waymonad
[Sway]: https://github.com/swaywm/sway
[i3]: https://github.com/i3/i3
[msu]: https://github.com/wfleming/dotfiles/blob/arch-linux/home_nodot/bin/msu
@gmykhailiuta
Copy link

gmykhailiuta commented Jan 27, 2021

Had same issue on Ubuntu 20.10. It turned out that wf-recorder was initially built without libavdevice and couldn't understand "v4l2" muxer option.
So it might be worth checking if all required libs are installed and rebuild.

My setup:

  • v4l2loopback-dkms 0.12.5-1
  • modprobe v4l2loopback card_label=Screen devices=1
  • ffmpeg 7:4.3.1-4ubuntu1
  • wf-recorder 8e49f2c (master branch).
  • Kernel: 5.10.0-10.2-liquorix-amd64

Other things I tried during debugging and which worked:

  • Check debug messages of v4l2loopback module in dmesg:
    modprobe v4l2loopback card_label=Screen debug=5
  • Whether loopback device got created:
    v4l2-ctl --list-devices
  • Try copying output from camera to v4l2loopback (here video2 is camera and video4 - v4l2 device):
    ffmpeg -f video4linux2 -i /dev/video2 -codec copy -f v4l2 /dev/video4
    and checking it's output: ffplay /dev/video4
  • Try to capture screen into a file:
    wf-recorder --file /tmp/video.mp4

@jmcclelland
Copy link

I'm on debian bullseye and followed @gmykhailiuta suggestion: sudo apt install libavdevice-dev. Then I re-compiled and the problem was resolved.

@ammen99 ammen99 closed this as completed Aug 9, 2023
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

6 participants