# Replacing raspivid | vlc RTSP with libcamera and mediamtx

**URL:** https://dietpi.com/forum/t/replacing-raspivid-vlc-rtsp-with-libcamera-and-mediamtx/17636
**Category:** Community Tutorials
**Created:** [10 August 2023 16:40 UTC](https://dietpi.com/forum/t/replacing-raspivid-vlc-rtsp-with-libcamera-and-mediamtx/17636 "2023-08-10T16:40:37Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![acyanic](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/a/779978/32.png) [@acyanic](https://dietpi.com/forum/u/acyanic)
#### Post date: [10 August 2023 16:40 UTC](https://dietpi.com/forum/t/replacing-raspivid-vlc-rtsp-with-libcamera-and-mediamtx/17636/1 "2023-08-10T16:40:37Z")

</div>

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](https://dietpi.com/forum/t/dietpi-resource-lock-raspivid-vlc-stream-issue/6179/30) 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.

TL;DR…  
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](https://forums.raspberrypi.com/viewtopic.php?t=326936) about ‘de-vlcing’  
and  
Ubuntu question [here](https://askubuntu.com/questions/1359032/can-not-play-rtsp-streams-with-linux/1363113#1363113) which has these answers:  
From this [Debian bug report](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=982299)

> '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](https://forum.videolan.org/viewtopic.php?f=13&p=520633#p520527):

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

**RTSP server**

So, I have switched to RTSP streaming solution [Mediamtx](https://github.com/bluenviron/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](https://github.com/MichaIng/DietPi/issues/5127).

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](https://dietpi.com/forum/t/libcamera-disable-legacy-camera-stack/6477)  
essentially

> 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](https://github.com/bluenviron/mediamtx#)

> apt install libfreetype6  
> download and unpack mediamtx

C. set RTSP [RpiCamera](https://github.com/bluenviron/mediamtx#raspberry-pi-cameras) parameters

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

> paths:  
> stream:  
> 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! 🙂

---

<div class="post-metadata">

### Author: ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)
#### Post date: [11 August 2023 07:41 UTC](https://dietpi.com/forum/t/replacing-raspivid-vlc-rtsp-with-libcamera-and-mediamtx/17636/2 "2023-08-11T07:41:30Z")

</div>

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

---

<div class="post-metadata">

### Author: ![acyanic](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/a/779978/32.png) [@acyanic](https://dietpi.com/forum/u/acyanic)
#### Post date: [11 August 2023 08:29 UTC](https://dietpi.com/forum/t/replacing-raspivid-vlc-rtsp-with-libcamera-and-mediamtx/17636/3 "2023-08-11T08:29:51Z")

</div>

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

---

<div class="post-metadata">

### Author: ![elevader](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/e/bbe5ce/32.png) [@elevader](https://dietpi.com/forum/u/elevader)
#### Post date: [25 August 2023 07:31 UTC](https://dietpi.com/forum/t/replacing-raspivid-vlc-rtsp-with-libcamera-and-mediamtx/17636/4 "2023-08-25T07:31:29Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![elevader](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/e/bbe5ce/32.png) [@elevader](https://dietpi.com/forum/u/elevader)
#### Post date: [13 February 2024 13:49 UTC](https://dietpi.com/forum/t/replacing-raspivid-vlc-rtsp-with-libcamera-and-mediamtx/17636/5 "2024-02-13T13:49:44Z")

</div>

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 [https://github.com/bluenviron/mediamtx/issues/1195#issuecomment-1343526773](https://github.com/bluenviron/mediamtx/issues/1195#issuecomment-1343526773) 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!

---

<div class="post-metadata">

### Author: ![blueyshark](https://dietpi.com/forum/user_avatar/dietpi.com/blueyshark/32/2877_2.png) [@blueyshark](https://dietpi.com/forum/u/blueyshark)
#### Post date: [6 March 2024 13:37 UTC](https://dietpi.com/forum/t/replacing-raspivid-vlc-rtsp-with-libcamera-and-mediamtx/17636/6 "2024-03-06T13:37:04Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Jappe](https://dietpi.com/forum/user_avatar/dietpi.com/jappe/32/1788_2.png) [@Jappe](https://dietpi.com/forum/u/Jappe)
#### Post date: [2 May 2026 11:47 UTC](https://dietpi.com/forum/t/replacing-raspivid-vlc-rtsp-with-libcamera-and-mediamtx/17636/7 "2026-05-02T11:47:23Z")

</div>

I found this thread just by accident, I’m researching right now a bit about mediaMTX and libcamera.

You would need to mux the video and the audio first, e.g. with `ffmpeg`, and then you can serve this stream via mediaMTX.  
Here an example for a v4l2 video device and sound is coming via alsa, mediaMTX is running on port 8554:

```auto
ffmpeg \
  -f v4l2 -i /dev/video0 \
  -f alsa -i hw:1,0 \
  -c:v libx264 -preset veryfast -tune zerolatency \
  -c:a aac -b:a 128k \
  -f rtsp rtsp://localhost:8554/live

```
