0

I have a problem when developing a livestream system with nginx-rtmp-module . I have consulted some systems, there is a function that when pushing the rtmp stream, the livestream systems can recognize the resolution of the stream -> from there it will encode to hls with the corresponding profiles. For example stream 720p produces hls file with 360p -> 720p , if stream 1080p will produce hls file with 360p -> 1080p . I have tried the ways but no success. So how can I check the resolution and redirect the rtmp stream to the appropriate application for encoding. Looking forward to everyone's advice.

1 Answers1

0

You should do this asynchronously:

Client ---RTMP--> NGINX ---Callback--> Server(Start a task to do this)

When publishing RTMP stream to NGINX, it will use HTTP callback to your Server, then you can start a asynchronouse task to detect the resolution and redirect the stream:

  1. Detect the stream by FFmpeg or ffprobe.
ffprobe -v quiet -print_format json -show_streams rtmp://ip/app1/stream1
  1. Redirect the stream to another application.
ffmpeg -f flv rtmp://ip/app1/stream1 -c copy -f flv rtmp://ip/app2/stream1
Winlin
  • 1,136
  • 6
  • 25
  • thank you very much, with your suggestion I will have to have an application in nginx (the callback will call that application to handle the ffmpeg command to redirect the stream) because of the stream I don't want the callback server to handle. (because I think the ffmpeg command on the callback server will consume resources on it, am I right). Can ffmpeg's options do this automatically without having to declare multiple locations and then redirect asynchronously? Looking forward to your further help. – bui the vuong Aug 23 '22 at 05:51
  • It does consume resources, but only a little, without transcoding. As I know, FFmpeg can't do this in your Nginx server, unless call FFmpeg API which is more complex. – Winlin Aug 24 '22 at 14:43
  • Thank you so much . All the best to you! – bui the vuong Aug 25 '22 at 02:29