Writing MJPEG to loopback device with FFMPEG fails on Ubuntu 20.04. Works on Rasperry Pi

582 views Asked by At

I have a script that writes MJPEG from an HDMI video capture card (/dev/video0) to a v4l2loopback device (/dev/video5). I compiled the v4l2loopback module from source. This script works fine on Raspberry Pi but fails on Ubuntu with this error: V4L2 output device supports only a single raw video stream. Is there a way around this or am I forced to transcode the HDMI capture output to rawvideo? I would prefer to get this working on Ubuntu in the same way it is working on Raspberry Pi.

Here is the FFMPEG command:

ffmpeg -input_format mjpeg -framerate 30 -s 1280x720 -i /dev/video0 -vcodec copy -f v4l2 /dev/video5

Full output of command:

Input #0, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 9137.845580, bitrate: N/A
Stream #0:0: Video: mjpeg (Baseline), yuvj422p(pc, bt470bg/unknown/unknown), 1280x720, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
[video4linux2,v4l2 @ 0x55eb0d461b40] V4L2 output device supports only a single raw video stream
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
1

There are 1 answers

0
Yllier123 On BEST ANSWER

I was using an outdated version of FFMPEG (4.2.X). I updated to 4.4.1-3 from this PPA and now everything works as expected. I hope this can be of use to someone someday dealing with the same hair-pulling issue.