The original post: /r/nginx by /u/ThornlessCactus on 2025-02-18 05:24:56.
I think I am doing something fundamentally wrong, please correct me if my architecture is wrong.
I have already made a config to record rtmp, and it is working.
server {
listen NGINXPORT;
chunk_size 4096;
buflen 1s;
notify_method get;
application app {
live on;
deny play all;
allow publish all;
on_publish http://localhost:xxxxx/publish;
on_record_done http://localhost:xxxxx/record_done;
recorder chunked {
record all;
record_interval 5s;
record_unique on;
record_path /var/www/html/recordings/;
}
}
I am using https://github.com/ossrs/srs to convert an rtmp stream into webrtc. it is also working. If I point the video device to NGINXPORT, i get the recordings. if i point it ot the srs rtmp port i get webrtc stream. Is there a way to do both? That is, I point the device to nginx, nginx records it but acts as a client to send to webrtc? One way i can think of is to use exec_done callback to execute ffmpeg -re -i $recordedname … SRS_RTMP_URL, so that after each segment is saved it is streamed to srs. Is there a better way? I think calling ffmpeg each time will become resource heavy, but i could be wrong, but it will increase the latency of the webrtc playback by 5 seconds (because record_interval is 5s). Is there a way to make nginx rtmp module forward the data in parallel?