简体   繁体   English

Nginx Rtmp 模块 - 在将 stream 重定向到另一个应用程序之前,如何在将 rtmp stream 推送到服务器时检查分辨率?

[英]Nginx Rtmp Module - How to check resolution when pushing rtmp stream to server before redirecting stream to another application?

I have a problem when developing a livestream system with nginx-rtmp-module.使用 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.我咨询了一些系统,有一个function,当推送rtmp stream时,直播系统可以识别stream的分辨率,并将其编码为相应的配置文件。 For example stream 720p produces hls file with 360p -> 720p, if stream 1080p will produce hls file with 360p -> 1080p.例如 stream 720p 产生 360p -> 720p 的 hls 文件,如果 stream 1080p 将产生 360p -> 1080p 的 hls 文件。 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.那么如何检查分辨率并将 rtmp stream 重定向到适当的应用程序进行编码。 Looking forward to everyone's advice.期待大家的建议。

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: 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.通过FFmpeg或ffprobe检测stream。
ffprobe -v quiet -print_format json -show_streams rtmp://ip/app1/stream1
  1. Redirect the stream to another application.将 stream 重定向到另一个应用程序。
ffmpeg -f flv rtmp://ip/app1/stream1 -c copy -f flv rtmp://ip/app2/stream1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM