简体   繁体   English

NGINX 和 FFMPEG 生成动态自适应流

[英]NGINX and FFMPEG generate dynamic adaptive streaming

In this configuration file https://github.com/TareqAlqutami/rtmp-hls-server/blob/master/conf/nginx.conf#L24-L30在这个配置文件https://github.com/TareqAlqutami/rtmp-hls-server/blob/master/conf/nginx.conf#L24-L30

for each received stream, transcode for adaptive streaming This single ffmpeg command takes the input and transforms the source into 4 different streams with different bitrates and qualities.对于每个接收到的 stream,为自适应流转码此单个 ffmpeg 命令接受输入并将源转换为具有不同比特率和质量的 4 个不同流。 # these settings respect the aspect ratio. # 这些设置尊重纵横比。

How we can dynamically generate variants?我们如何动态生成变体? ie for 1080p input generate all variants, but for 240p input generate no variants即对于 1080p 输入生成所有变体,但对于 240p 输入不生成任何变体

My startup works without error You need to configure the log and see what error it gives.我的启动工作没有错误您需要配置日志并查看它给出的错误。 But another solution is to check manually You may be using a codec that is not installed但另一种解决方案是手动检查您可能正在使用未安装的编解码器

I will check your tank, maybe I can contribute here我会检查你的坦克,也许我可以在这里贡献

application live {
            live on; # Allows live input
            exec ffmpeg -i rtmp://localhost/live/$name -threads 8
                        -c:v libx264 -profile:v baseline -b:v 768K -s 640x360 -vf "drawtext= fontcolor=red: fontsize=20: fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf: text='360': x=10: y=10:" -f flv -c:a aac -ac 1 -strict -2 -b:a 96k rtmp://localhost/show/$name_360
                        -c:v libx264 -profile:v baseline -b:v 1024K -s 960x540 -vf "drawtext= fontcolor=red: fontsize=20: fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf: text='480': x=10: y=10:" -f flv -c:a aac -ac 1 -strict -2 -b:a 128k rtmp://localhost/show/$name_480
                        -c:v libx264 -profile:v baseline -b:v 1920K -s 1280x720 -vf "drawtext= fontcolor=red: fontsize=20: fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf: text='720': x=10: y=10:" -f flv -c:a aac -ac 1 -strict -2 -b:a 128k rtmp://localhost/show/$name_720
                        -c:v libx264 -profile:v baseline -b:v 4000K -s 1920x1080 -vf "drawtext= fontcolor=red: fontsize=20: fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf: text='720': x=10: y=10:" -f flv -c:a aac -ac 1 -strict -2 -b:a 128k rtmp://localhost/show/$name_1080;

        }


        application show {
            live        on;     # Allows live input from above
            hls         on;     # Enable HTTP Live Streaming
            # hls_fragment  5s;
            # Pointing this to an SSD is better as this involves lots of IO
            hls_path /dest;
            #hls_variant _240 BANDWIDTH=288000;            
            hls_variant _360 BANDWIDTH=448000;
            hls_variant _480 BANDWIDTH=1152000;
            hls_variant _720  BANDWIDTH=2048000;
            hls_variant _1080 BANDWIDTH=4096000; 
        }


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

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