A lightweight RTSP (Real Time Streaming Protocol) server written in C using GStreamer and libgstrtspserver.
This project demonstrates how to set up a simple video streaming service that clients like VLC or FFplay can connect for redering the video.
Note The pipeline currently supports video file only but can easily be updated to add audio plugin elements.
- Simple RTSP server built using the GStreamer RTSP API
- Supports local MP4 or camera stream sources
- Lightweight and portable β builds cleanly with CMake or Makefile
- Out-of-tree build support to keep your source tree clean
- Ready for integration into embedded or edge video systems
Ensure you have the required development tools and GStreamer libraries installed.
The repository includes a helper script for this:
sudo ./install_dependencies.shThis script installs:
cmake,pkg-config,vimlibgstreamer1.0-devlibgstrtspserver-1.0-devgstreamer1.0-plugins-bad,gstreamer1.0-plugins-uglygstreamer1.0-libavlibx264-dev
π The script checks for each dependency and installs it only if missing.
You can build the RTSP server using CMake (recommended) or a Makefile (simple alternative).
This is the cleanest approach since it keeps build artifacts separate from your source files.
mkdir -p build
cd buildPoint CMake to your project source (assuming itβs the parent directory):
cmake ..If your CMakeLists.txt is located elsewhere, replace .. with the correct path.
makeAfter the build completes successfully, youβll find:
build/rtsp_server
sudo make installBy default, this installs to /usr/local/bin/rtsp_server.
You can build in Release or Debug mode:
cmake -DCMAKE_BUILD_TYPE=Release ..Speed up compilation using all CPU cores:
make -j$(nproc)cmake -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=../bin ..cmake -DCMAKE_INSTALL_PREFIX=/opt/rtsp ..For a simple build using the provided Makefile, run:
makeThis generates the rtsp_server binary in the same directory.
To clean up:
make cleanOnce built, you can start the RTSP server directly:
./rtsp_serverThe server will start listening (default port 8554).
You can test the stream using:
ffplay rtsp://127.0.0.1:8554/testor using VLC:
Media β Open Network Stream β rtsp://127.0.0.1:8554/test
If you want a completely fresh build:
cd build
rm -rf *
cmake ..
make- If you see:
install it:
Could NOT find PkgConfigsudo apt-get install pkg-config
If GStreamer libraries are missing, rerun:
sudo ./install_dependencies.shIf port 8554 is occupied:
sudo lsof -i :8554
sudo kill <PID>Then restart your RTSP server.
rtsp_server/
βββ CMakeLists.txt
βββ Makefile
βββ src/
β βββ rtsp_server.c
βββ install_dependencies.sh
βββ LICENSE
βββ README.md
# Step 1: Install dependencies
sudo ./install_dependencies.sh
# Step 2: Create and enter build directory
mkdir -p build && cd build
# Step 3: Configure with CMake
cmake ..
# Step 4: Build
make -j$(nproc)
# Step 5: Run
./rtsp_serverThis project is distributed under the terms of the MIT LICENSE file.
You are free to use, modify, and distribute it as permitted by the license.
Maintained by Pratik Tambe
For issues or suggestions, please open a GitHub issue.