[直播推流] 本地创建 nginx服务器

发布于:2025-06-15 ⋅ 阅读:(13) ⋅ 点赞:(0)

需要将 nginx 安装在纯英文的路径,不然会报错
需要将 nginx 安装在纯英文的路径,不然会报错
需要将 nginx 安装在纯英文的路径,不然会报错
类似这个报错

[emerg] 11240#2204: CreateFile() “F:\迅雷下载\nginx\nginx/conf/nginx.conf” failed (1113: No mapping for the Unicode character exists in the target multi-byte code page)

环境搭建

参考这个文档
https://blog.csdn.net/stalin_/article/details/128968989

我下载之后本地没有 nginx.conf 文件,自己直接新建一个就行。
启动 nginx 可以使用

 start nginx.exe

本地配置好的文件:有需要可以直接下载,或者私聊我。
https://download.csdn.net/download/dss875914213/91008307

本地测试

可以使用 ffmpeg 测试
推流

ffmpeg -f dshow -video_size 1280x720 -framerate 30 -i video="Integrated Camera" -c:v libx264 -preset ultrafast -tune zerolatency -f flv rtmp://localhost:1935/live/stream_key

拉流

ffplay rtmp://localhost/live/stream_key

其他

nginx.conf 配置可以用这个,在将 nginx-rtmp-module 目录下的 stat.xsl 拷贝到 html 目录下

#user  nobody;
# multiple workers works !
worker_processes  2;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  8192;
    # max value 32768, nginx recycling connections+registry optimization = 
    #   this.value * 20 = max concurrent connections currently tested with one worker
    #   C1000K should be possible depending there is enough ram/cpu power
    # multi_accept on;
}

rtmp {
    server {
        listen 1935;#监听端口,若被占用,可以更改
        chunk_size 4000;#上传flv文件块儿的大小
        application live { #创建一个叫live的应用
             live on;#开启live的应用
             allow publish 127.0.0.1;#
             allow play all;
        }
    }
}
http {
    server {
        listen 8080;
        location /stat {
            rtmp_stat all;

            # Use this stylesheet to view XML as web page
            # in browser
            rtmp_stat_stylesheet /stat.xsl;
        }

        location /stat.xsl {
            # XML stylesheet to view RTMP stats.
            # Copy stat.xsl wherever you want
            # and put the full directory path here
            root html;
        }
    }
}

这样就可以在 localhost:8080/stat 查看服务器当前的状态了
在这里插入图片描述