The latest version of the Raspberry Pi operating system brings significant changes. Apart from the ususal software updates to the Debian 11 Bullseye base, Raspbian now got rebranded to Raspberry Pi OS. It now comes with a completely new software stack to access its various camera options called libcamera. Unfortunately that means that the old commands raspivid and raspistill will no longer work. So it’s time to update our previous post about how to stream with a Raspberry Pi.

Streaming with libcamera on Raspberry Pi OS

Luckily, there is not too much to change on the surface: For the most part, we just have to use the new command and change some parameter names. Our earlier example that streams at 720p in h264 now works like this:

libcamera-vid -t 0 --inline --listen --width 1280 --height 720 -b 15000000 --profile high --level 4.2 --framerate 30 -o tcp://

The --inline option is quite interesting. It forces the stream header information to be included with every I (intra) frame. That makes it easy for a client to join a stream somewehere in the middle. Neat!

But just as before, libcamera never produced a fluid stream for me on my Raspberry Pi 3B+. So let’s look at alternatives.

Update 2023-02-07: I revisited libcamera in its current version and got it to work on my Raspi 3B+. I use the libav plugin to send the stream via RTMP to my target:

# I increased the bitrate manually to 2MBit/s
libcamera-vid --bitrate 2097152 --profile high --level 4.2 --nopreview -t 0 --width 1920 --height 1080 --framerate 30 --codec libav --libav-format flv -o "rtmp://"

VLC and ffmpeg streaming on Raspberry Pi OS

The VLC and ffmpeg interface did not change and works just as I described in how to stream with a Raspberry Pi. But they both depend on the old camera interface that raspivid and raspistill used. We have to reenable that before VLC and ffmpeg can be used to stream.

Enable Legacy Camera mode for VLC and ffmpeg

If you try to use VLC or ffmpeg on Raspberry Pi OS, you might encounter this VLC error:

[0000007f7c4cec80] v4l2 stream error: cannot start streaming: Invalid argument
[0000007f84000c90] main input error: Your input can't be opened
[0000007f84000c90] main input error: VLC is unable to open the MRL 'v4l2:///dev/video0'. Check the log for details.

Ot the following error with ffmpeg:

[video4linux2,v4l2 @ 0x558969a030] fd:3 capabilities:a5a00001
[video4linux2,v4l2 @ 0x558969a030] Cannot find a proper format for codec 'h264' (id 27), pixel format 'none' (id -1)
/dev/video0: Invalid argument

That’s because they both rely on the old Raspbian camera subsystem. You can reenable the legacy camera system using raspi-config:

sudo raspi-config

Now select the interface options:

And enable the legacy camera support:

Now VLC and ffmpeg should work using /dev/video0 as before:

cvlc v4l2:///dev/video0 --v4l2-fps 30 --v4l2-width 1280 --v4l2-height 720 --v4l2-chroma h264 --sout '#standard{access=http,mux=ts,dst=}'
ffmpeg -v verbose -f v4l2 -input_format h264 -video_size 1920x1080 -framerate 30 -i /dev/video0 -c:v copy -an -f mpegts udp://

Fix ffmpeg operation not permitted error

Another issue that might pop up is a operation not permitted error with ffmpeg:

ffmpeg: ioctl(VIDIOC_STREAMON): Operation not permitted

You can work around that by increasing the gpu memory in the boot config file: