First of all, we need to do all the things indicated here: https://gist.github.com/DevStefIt/23b8971db7e3fe084d29f2c915fb7773 We need to modify the Nginx configuration file:
sudo vim /etc/nginx/nginx.conf
Then, have to add the following lines in the existing RTMP configuration (or create a new one if you do not have it)
. . .
rtmp {
server {
...
application live {
live on;
record off;
hls on;
hls_path /var/www/html/stream/hls;
hls_fragment 3;
hls_playlist_length 60;
hls_cleanup off;
dash on;
dash_path /var/www/html/stream/dash;
dash_cleanup off;
}
}
}
...
We need to configure a block in the sites-available
folder.
sudo vim /etc/nginx/sites-available/rtmp
And insert the following lines:
...
server {
listen 8088;
location / {
add_header Access-Control-Allow-Origin *;
root /var/www/html/stream;
}
}
types {
application/dash+xml mpd;
}
Port 8088
is chosen because it is different than the other chose ports.
We enable port 8088 in TCP mode on the firewall
sudo ufw allow 8088/tcp
We create the folders of interest
sudo mkdir -p /var/www/html/stream/hls
sudo mkdir -p /var/www/html/stream/dash
We also grant a reasonable access for the current user
sudo chown -R $USER:$USER /var/www/html/stream
sudo chmod -R 775 /var/www/html/stream
We reload Nginx
sudo systemctl reload nginx
If anyone has a Nvidia GPU that compatible with Cuda https://developer.nvidia.com/cuda-downloads you can use the GPU instead of the CPU however i have only done this via linux ubuntu 22.04, I did have to compile ffmpeg but was easy as nvidia listed it step by step https://docs.nvidia.com/video-technologies/video-codec-sdk/ffmpeg-with-nvidia-gpu/index.html#compiling-for-linux
streaming_commands.md
Stream your file via RTMP with you NVIDA GPU and leave the CPU to do only Audio (AAC) what is VERY little CPU used.
ffmpeg -y -vsync 0 -i input -c:v h264_nvenc -c:a aac -tune zerolatency -f flv rtmp://127.0.0.1/live/ARBITRARY_NAME
ffmpeg_dash.sh
ffmpeg -y -vsync 0 -i input -c:v h264_nvenc -c:a aac -tune zerolatency -f dash ARBITRARY_NAME.mpd