6

I have a Logitech Webcam C930e on /dev/video0. I can use this for doing video conferences (e.g. jitsi). However, the video from this webcam is too high and too broad. I would like to have a "cropped" version of /dev/video0 that does not show the seaside picture on the wall.

First, I tried to set v4l2 options to achieve this, but did not succeed:

$ v4l2-ctl -d /dev/video0 --get-cropcap
Crop Capability Video Capture:
    Bounds      : Left 0, Top 0, Width 640, Height 360
    Default     : Left 0, Top 0, Width 640, Height 360
    Pixel Aspect: 1/1

$ v4l2-ctl -d /dev/video0 --get-selection target=crop_bounds
Selection: crop_bounds, Left 0, Top 0, Width 640, Height 360, Flags:

$ v4l2-ctl -d /dev/video0 --set-selection target=crop_bounds,flags=crop,top=10,left=10,width=100,height=100
VIDIOC_S_SELECTION: failed: Inappropriate ioctl for device

After that, I followed another idea: I tried to use v4l2loopback to create another device /dev/video2. After that I would have tried to use ffmpeg to connect /dev/video0 to /dev/video2 (see https://github.com/umlaeute/v4l2loopback/wiki and https://video.stackexchange.com/questions/4563/how-can-i-crop-a-video-with-ffmpeg).

So now, I am out of ideas. Can someone give advice?

2
  • I'm having the same issue and virtual device isn't an option for me. Did you happen to find the solution on driver level (e.g. with v4l2-ctl)?
    – cprn
    Commented Feb 21 at 16:53
  • Sorry, I didn't find a solution on driver level.
    – Markus
    Commented Feb 28 at 21:45

1 Answer 1

13

Lines below create a loopback video device /dev/video5. After that ffmpeg is used to connect /dev/video0 to /dev/video5, but crop and hflip the stream on its way.

sudo apt-get install v4l2loopback-dkms 
sudo modprobe v4l2loopback video_nr=5
ffmpeg -i /dev/video0 -f v4l2 -pix_fmt yuv420p -filter:v "hflip,crop=400:400:0:0" /dev/video5

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .