How to fix Raspberry Pi libcamera-vid H.264 livestream stuck at first frame
Problem
If you’re using libcamera-vid
to livestream h264 video as shown in our previous post using a command such as:
libcamera-vid -t 0 --width 1920 --height 1080 --codec h264 --inline --listen -o tcp://0.0.0.0:8888
with VLC etc as a client, you might experience VLC displaying the first frame but then getting stuck even though libcamera-vid
showing that frames are being captured.
For me, this issue occured only on the Raspberry Pi 5.
Solution
I’m not 100% positive on what causes this issue but using mjpeg
instead of h264
as the codec seems to fix the issue. You can use the following command to stream MJPEG video:
libcamera-vid -t 0 --width 1920 --height 1080 --codec mjpeg --inline --listen -o tcp://0.0.0.0:8888
and the following command to stream it:
vlc tcp/mjpeg://192.168.1.185:8888/