3

What I am trying to achive is to redirect my camera /dev/video0 with a custom video file.

Desired Reasult:

When opened a application like cheese or websites like jitsi which process the buffer from my camera. Is it possible to use already captured video file as camera input.

Previous attempt:

I followed a answer from this answer but i am getting a error message as

[video4linux2,v4l2 @ 0x556927267880] ioctl(VIDIOC_G_FMT): Invalid argument
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 -- 
Conversion failed!

on executing the command

ffmpeg -re -i ~/Videos/Webcam/sample.webm -map 0:v -f v4l2 /dev/video0
Dev-il
  • 51
  • hi please edit your question and add the command that produces the error. – d1bro May 27 '21 at 18:32
  • I just did. Could you see that again? – Dev-il May 27 '21 at 18:35
  • If you follow the steps for PC here https://askubuntu.com/a/1227239 and skip the net cat part and use your video file as the source for the included ffmpegcommand… you should be good to go. – Raffa May 27 '21 at 20:17
  • Please run apt policy v4l2loopback-utils v4l2loopback-dkms and check your installed version... 0.12.2-1 works fine but earlier and later versions have issues. The kind of error you get tells me you most likely have a version grater than 0.12.2-1 installed... I have seen this error before. – Raffa May 27 '21 at 23:39

1 Answers1

1

I just solved after a couple of hours. On this answer the /dev/video0 was actually representing the virtual camera created by v4l2loopback but in my case as I am on laptop /dev/video0 actually points to integrated webcam. So what I did is:

ls /dev/video*

And note the devices returned now you can load the module like

sudo modprobe v4l2loopback

and now a new device pointer should be preset. Check it by

ls /dev/video*

Notice the new device added and that's what you have to work with. Keeping this in mind now you can follow this thread.

Pablo Bianchi
  • 15,657
Dev-il
  • 51
  • 1
    This was already mentioned in the answer you linked to: "Note that the actual video number may vary depending if an existing device is already using /dev/video0. Check output of ls /dev/video* or v4l2-ctl --list-devices". – llogan May 28 '21 at 16:12