To receive RTSP feed at server we need to install NginX and RTMP module at server side.
Then we need to configure rtmp configure at nginx.conf from /etc/nginx/nginx.conf
rtmp {
server {
listen 8000; # Listen on standard RTMP port
chunk_size 4000;
application live {
live on;
# Turn on HLS
# HLS Configuration
hls on;
hls_path /var/www/chatapp.thinkfoundation.com.bd/hls/;
hls_fragment 3;
hls_playlist_length 60;
# Use a custom name for the HLS segment files
hls_fragment_naming system;
hls_fragment_naming_granularity 1;
}
}
}
and also update the server block of nginx config file. It could be nginx.conf or /etc/nginx/sites-available/ folder config file.
Use following server block to get the hls feed
Use following server block to get the hls feed
server {
listen 80;
server_name chatapp.thinkfoundation.com.bd; # replace with your domain or IP address
location / {
root /var/www/chatapp.thinkfoundation.com.bd/hls/; # replace with the path to your HLS files
add_header Cache-Control no-cache;
add_header 'Access-Control-Allow-Origin' '*' always;
# You can add more headers as needed
# Enable CORS for HLS
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
# Handle HLS files
location ~ \.m3u8$ {
types { application/vnd.apple.mpegurl m3u8; }
add_header Cache-Control no-cache;
add_header 'Access-Control-Allow-Origin' '*' always;
# You can add more headers as needed
}
location ~ \.ts$ {
add_header Cache-Control no-cache;
add_header 'Access-Control-Allow-Origin' '*' always;
# You can add more headers as needed
}
}
}
Now your live feed url will be:
example
example
http://chatapp.thinkfoundation.com.bd/.m3u8
Make sure that you send your local rtsp feed to remote server using following command:
ffmpeg -i "rtsp://admin:hik12345@192.168.100.40:554/Streaming/Channels/101" -filter:v fps=fps=30 -crf 40 -preset ultrafast -vcodec libx264 -f flv "rtmp://157.245.58.124:8000/live"
you need ffmpeg library to execute upper command to send rtsp feed to rtmp server.
ffmpeg -i "rtsp://admin:hik12345@192.168.100.40:554/Streaming/Channels/101" -filter:v fps=fps=30 -crf 40 -preset ultrafast -vcodec libx264 -f flv "rtmp://157.245.58.124:8000/live"
you need ffmpeg library to execute upper command to send rtsp feed to rtmp server.
0 Comments