Home > database >  Nginx Rtmp Module - How to check resolution when pushing rtmp stream to server before redirecting st
Nginx Rtmp Module - How to check resolution when pushing rtmp stream to server before redirecting st

Time:08-25

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.

CodePudding user response:

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
  • Related