# rtsp-simple-server
**Repository Path**: huihui308/rtsp-simple-server
## Basic Information
- **Project Name**: rtsp-simple-server
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: david
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2022-05-17
- **Last Updated**: 2022-09-28
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Rtsp simple server
- [Description](#description)
- [Prepare](#prepare)
- [Directory](#directory)
- [Operation](#operation)
- [Boot](#boot)
- [Notice](#notice)
- [Reference](#reference)
# Description
This project use rtsp-simple-server and python code to construct a rtsp server, it test success on ubuntu18.04.
# Prepare
## install ffmpeg
```
$ sudo apt update
$ sudo apt install ffmpeg
```
## compile ffmpeg in order to support GPU encode
To compile ffmpeg with NVIDIA we need ffnvcodec too. Clone git repo:
```
$ mkdir ~/nvidia/ && cd ~/nvidia/
$ git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
```
Install ffnvcodec on Ubuntu or Debian:
```
$ cd nv-codec-headers && sudo make install
```
Get ffmpeg source code, run:
```
$ cd ~/nvidia/
$ git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg/
```
Install GNU gcc compiler collection and libs, run:
```
$ sudo apt install build-essential yasm cmake libtool libc6 libc6-dev unzip wget libnuma1 libnuma-dev
```
Configure ffmpeg with NVIDIA GPU support:
```
$ cd ~/nvidia/ffmpeg/
$ ./configure --enable-nonfree --enable-cuda-nvcc --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64
```
Compile it, execute:
```
$ make -j $(nproc)
```
Verify executable:
```
$ ls -l ffmpeg
$ ./ffmpeg
```
# Directory
## stream
You should put you push stream in that directory, support mp4 stream.
# Operation
## Add new push stream url
Add code in script/ds_master.py:
```
rtsp_stream_dict = {
'rtsp://localhost:8554/mystream1':'src_4k_24fps.mp4',
'rtsp://localhost:8554/mystream2':'src_4k_24fps.mp4',
'rtsp://localhost:8554/mystream3':'src_4k_24fps.mp4',
'rtsp://localhost:8554/mystream4':'src_4k_24fps.mp4'}
```
## Execute
Execute python3 script, such as:
```
$ cd script
$ python3 rtsp_publish.py
```
## Test
Use VLC or gstream pull rtsp stream.
# Auto boot
```
$ sudo cp auto-boot/rc-local.service /etc/systemd/system/rc-local.service
$ sudo cp auto-boot/rc.local /etc/rc.local
$ sudo chmod +x /etc/rc.local
```
# Notice
# Reference
```
https://github.com/aler9/rtsp-simple-server#standard
https://www.codeleading.com/article/55531668480/
https://www.cyberciti.biz/faq/how-to-install-ffmpeg-with-nvidia-gpu-acceleration-on-linux/ ffmpeg support gpu
```