Solution to my ffmpeg issue!

Thank you so much woggle from FurNet.

The command I ran was:

ffmpeg -f video4linux2 -input_format mjpeg -framerate 60 -video_size 1920x1080 -i /dev/video0 -c copy -f video4linux2 /dev/video9

I don't know why the arguments need to be in this order, but it gave me the streamcopy I needed.

Well, it gave me one streamcopy. Turns out that only one application can access a virtual webcam, same as only one application can access a physical webcam. So next step is to make more loopback devices and streamcopy to all of them.

#V4L2 #Video4Linux #v4l2loopback #ffmpeg

I've reached the point with ffmpeg where I really need someone to explain something to me because I'm getting inconsistent results.

To get ffplay to show me the video I want to stream to my v4l2loopback device, I did this:

ffplay -f video4linux2 -input_format mjpeg -framerate 60 -video_size 1920x1080 /dev/video0

And it worked! It pops up a window showing video from my webcam at the correct resolution and framerate, in MJPEG as expected.

But when I do this:

ffmpeg -i /dev/video0 -c copy -f video4linux2 -input_format mjpeg -framerate 60 -video_size 1920x1080 /dev/video9

The stream goes back to raw video at 5fps.

Is there something wrong with my syntax? I've noticed that if I move -i /dev/video0 anywhere except as the first argument in the command, I get errors. For example I do:

ffmpeg -c copy -f video4linux2 -input_format mjpeg -framerate 60 -video_size 1920x1080 -i /dev/video0 /dev/video9

And the error I get is:

Unknown decoder 'copy'
Error opening input file /dev/video0.
Error opening input files: Decoder not found

#V4L2 #Video4Linux #v4l2loopback #ffmpeg

Was I able to find documentation of the commands? Yes, doing v4l2-ctl --help-vidcap, which is documented in the man page. That probably should have just been another man page.

Was I able to change the pixelformat on my camera to MJPG? Yes, by doing v4l2-ctl -d /dev/video0 --set-fmt-video=pixelformat=MJPG.

Does this make a difference when I do mpv /dev/video0 to check the video output? Nope! It gets set back to YUYV raw video at 5fps.

So I do actually need to figure out how to set the correct format in ffmpeg or whatever I use to stream to the loopback device?

#V4L2 #Video4Linux #V4L2loopack #WhereIsTheManual

Is there complete documentation of v4l2-ctl anywhere? Because the man page I got with the package isn't it.

I saw the --list-formats-ext option recommended to list all the available formats for a device, which works, but isn't documented. I'm guessing that I need a corresponding option to set the format I want, but I have no idea because the documentation isn't there.

#V4L2 #Video4Linux #WhereIsTheManual

I have a #webcam on a #Linux system and hypothetically, if I were to do the video game streamer thing, I might want to use it to feed video from that camera to two apps simultaneously, namely:

  • Head tracking software for a video game
  • Face tracking software for a VTube avatar

But from what I've seen, only one application on a Linux system using V4L2 can get a video stream from a webcam at a time.

The solution I've seen proposed to this problem is v4l2loopback, but none of the sources I've seen bothered to explain how to use it, and the wiki they link to is bare-bones and doesn't seem to explain much either.

Furthermore, I want to be sure that the camera is providing video to these apps at its maximum framerate and not just its maximum resolution, and I don't know how I'd configure this. Or... really anything at all.

Is there any actually relevant documentation I should be reading to solve this problem?

#Video4Linux #V4L2 #V4L2loopback

Linux Fu: Fake Webcams Have Many Uses

Dealing with text streams is a fundamental skill for the Linux power user. You can sort, merge, and search text files easily from the command line. What if you could do the same thing with video? W…

Hackaday

Ich nutze gerade mpv mit 'av://v4l2:/dev/v4l/by-id/usb-TP_BRESSER_DST-1028_01.00.00-video-index0 --profile=low-latency --untimed'.

Wenn jemand Ideen hat wie man die Video-Latenz noch weiter drücken kann gerne her damit.

#soldering #video #linux #video4linux

One more existential reason for v4l2-loopback: testing video4linux features other than v4l2-loopback.

It is always nice to have a module in the stack that can pretend to be a piece of hardware in various end-to-end tests.

Just writing these down so that I can make a credible cover letter at the time :-)

I did this one big refactor few days ago: https://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd.git/commit/?h=v4l2-loopback&id=ccb1b6e1247887be17bf22b3809c50848e87a4db

I'm still editing it up until I'm happy with capture/output separation and some other things related (e.g. life-cycle and removal).

Obviously once I sent a patch set I will squash everything before sending...

#video4linux #linux #kernel #media
V4L2LOOPBACK_CTL_ADD: Reburnish the API - kernel/git/jarkko/linux-tpmdd.git - Linux TPM Device Driver

Multiple capture/output devices issue in the OOT driver and v4l2-loopback. It has the unfinished "SPLIT_DEVICES" compilation options, which I DO NOT fully cope with. I don't get what the heck they are aiming for TBH.

A video device can be either something like camera or something that takes input from client and displays that, e.g. similar device to ChromeCast would be a good example in this context.

I'm aligning to a solution where the initial "ADD" ioctl has:

1. flags (for setting the RW properties)
2. video_nr
3. video_fd (for server to read OR write)

And the direction is determined by flags. I did not fully understand why OOT driver aimed to do both capture and output device simultaneously, which does bother me a bit since it would be best to know the original reasoning, even if the conclusions were wrong.

Moving slowly in this area still and experimenting with options.

#linux #kernel #media #video4linux
After trying bunch of things over the last few weeks I finally have a test program for feeding the data for a video loopback device, i.e. to work as fake webcam:

- Has zero dependencies other than libc. Draws the frames, converts the pixel formats and writes them to the device.
-.Has optional debug display using minifb.
- Predictable cyclic motion, which useful in future for automated testing.

Repository: https://codeberg.org/jarkko/v4l2-loopback-test/
BuildRoot package: https://codeberg.org/jarkko/linux-tpmdd-test/src/branch/main/package/v4l2-loopback-test

I've not been able to make any major changes to the driver I would like to do because it does not make much when being blind. Now it is finally possible to forget user space and move on to the kernel changes.

#linux #kernel #media #video4linux
v4l2-loopback-test

v4l2-loopback-test

Codeberg.org