Replacing raspivid | vlc RTSP with libcamera and mediamtx

This is a solution post rather than a problem post. I have now abandoned vlc as a streaming solution.

Last year I had a very long topic about streaming problems of the classic Raspberry Pi webcam raspivid | cvlc RTSP solution.

I had issues with a stalling system and stuttering video stream.
Viewing the stream would have 40-50% dropped frames.
This rendered the stream unreadable by motioneye.

I discovered VLC is not optimal anymore - it’s broken for mortals.
I upgraded DietPi to the ‘modern’ libcamera stack.
I used a RTSP streamer solution: Mediamtx.
I used DietPi Bullseye (not Buster), Bookworm was too new.

VLC no longer

Raspberry forum comment here about ‘de-vlcing’
Ubuntu question here which has these answers:
From this Debian bug report

'We had to disable those plugins as liblivemedia constains non-free code. See #981439. Maybe that’s worth a NEWS entry and a note in the release-notes”

And from VLC forums:

“Debian VLC builds do not support RTSP by Debian policy decision"

RTSP server

So, I have switched to RTSP streaming solution Mediamtx (rebranded RTSP-simple-server)

I tested first by installing Raspbian OS for lib camera and mediamtx, and all went very well.
My motioneye page immediately started showing the stream that had been dead for months.

I went back to DietPi - because I like to be slim.

Libcamera on Dietpi

This was little more tricky, as libcamera is not native on DietPi yet. modern vs legacy.

I tried Bookworm - but that failed on some dependencies, and too new and tricky for me.
I went back to Buster.

A. install and enable libcamera per this topic

  1. Enable ‘8: RPi Camera’ at DietPi-Config/Display Options/
  2. added ‘camera_auto_detect=1’ to the /boot/config.txt
    and comment out start_x=1
  3. Installed libcamera ‘apt install libcamera-apps-lite’

B. install mediamtx

apt install libfreetype6
download and unpack mediamtx

C. set RTSP RpiCamera parameters

Edit the mediamtx.yml file to add the camera path…

source: rpiCamera

I used path ‘stream’ rather than ‘cam’, as that already used by motioneye.
(The instructions are little obscure to understand the full URL based on paths.)

D. run Mediamtx as sudo.

sudo ./mediamtx

E. add systemd service

F. view stream in motioneye
and spend many happy hours tweaking detection parameters! :slight_smile:


thx for sharing. I moved your post to Community Tutorials. Hope that’s fine with you.

1 Like

Of course. It’s an honour to be promoted from problem to tutorial.

1 Like

Nice, i dabbled around with mediamtx on raspiOS and a frigate server, mediamtx does a great job indeed.
Didn’t investigate though how to get mediamtx working with dietpi like you did, will give it a go now and follow your steps, thanks for the steps.

Had ssd die on me so i had to reinstall and went with dietpi instead raspi, heck of faster shutdowns and reboots this way.
It’s a rpi3 with bookworm armv8 diepti, i was getting some liberror, quick search led to and installing apt install libcamera0 which i think should be installed instead of libcamera-apps-lite and cam works.

Glad that dietpi can handle mediamtx and thanks for the quick info acyanic!

Hi there. Has anyone had success adding audio from a USB microphone to the RTSP stream? I’m not using motioneye as I don’t think it supports audio.