What is the right ffmpeg output format for a v4l2-loopback device?

Solution 1:

v4l2loopback v0.11.0 has a bug which is now fixed, so there is no need to manually change the source code as shown in the bug report. As of now there is no newer release version with the fix, so upgrade to the master branch which contains the fix.

Installing

Arch Linux

Until a new release version comes out you can use the AUR package v4l2loopback-dkms-git instead of v4l2loopback-dkms.

Debian & Ubuntu

sudo apt-get remove v4l2loopback-dkms
sudo apt-get install build-essential libelf-dev linux-headers-$(uname -r) unzip
wget https://github.com/umlaeute/v4l2loopback/archive/master.zip
unzip master.zip
cd v4l2loopback-master
make
sudo make install
sudo depmod -a
sudo modprobe v4l2loopback

ffmpeg examples

Grab desktop:

ffmpeg -f x11grab -framerate 25 -video_size 1280x720 -i :0.0+0,0 -f v4l2 /dev/video0

Send file:

ffmpeg -re -i input.mp4 -f v4l2 /dev/video0

Playing the video

ffplay

ffplay -f v4l2 /dev/video0

mpv

mpv --demuxer-lavf-format v4l2 /dev/video0

VLC

MediaOpen Capture Device