Flipping webcam image with FFmpeg

Install

Load v4l2loopback module

# modprobe v4l2loopback devices=1 video_nr=10 card_label="Loopback Camera" exclusive_caps=1
  • devices=1 - create one device
  • video_nr=10 - choose device id, the path will be /dev/video10
  • card_label=“Loopback Camera” - choose name
  • exclusive_caps=1 - reports CAPTURE/OUTPUT capabilities exclusively (applications couldn’t see my device without this option)
    See if you can see your new device:
$ v4l2-ctl --list-devices 
Loopback Camera (platform:v4l2loopback-000):
	/dev/video10

Run ffmpeg

$ ffmpeg -f v4l2 -i /dev/video4 -vf "vflip,format=yuv420p" /dev/video10
  • -f v4l2 - input format
  • -i /dev/video4 - input device (your webcamera)
  • -vf “vflip,format=yuv420p” - flip it! and set pixel format
  • -f v4l2 - output format
  • /dev/video10 - output device
    In an application select your new “Loopback Camera” device.
2022-01-30