node-rtsp-stream、jsmpeg.min.js实现rtsp视频在web端播放

  1. 服务地址(私有):https://gitee.com/nnlss/video-node-server

2.node-rtsp-stream 需要安装FFMPEG;

3.给推拉流做了开关,可借助http请求,有更好方式可联系;

4.存在问题:

1).对于网络摄像头,直接推拉流,测试6h+界面不卡顿,延迟1s以内(未精确测试延迟时间)

2).对于物料上的rstp, 由于工程师一直给rtsp推流,即便node服务结束进程,FFMPEG依然可以获取到rtsp

5.node 服务打包

  1. 安装ncc

    javascript 复制代码
    npm install -g @zeit/ncc

2.安装成功

javascript 复制代码
ncc version
  1. ncc 打包node 为单文件
javascript 复制代码
ncc build index.js -o nodeServer

报错:

javascript 复制代码
ncc: Version 0.22.3
ncc: Compiling file index.js
Error: error:0308010C:digital envelope routines::unsupported

原因:node 版本问题node.js - Error message "error:0308010C:digital envelope routines::unsupported" - Stack Overflow

利用nvm 切换版本

javascript 复制代码
nvm use 16.15.0

重新打包:

javascript 复制代码
ncc build index.js -o nodeServer

生成文件目录nodeServer/index.js:

javascript 复制代码
-nodeServer

       --index.js

cmd进入目录执行:

javascript 复制代码
node index.js

启动服务成功

本地部署前后端配置nginx

复制代码
#user  nobody;
worker_processes  1;

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

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       8081;
        server_name  localhost;
        #charset koi8-r;
        charset utf-8;
        #access_log  logs/host.access.log  main;

        location / {
        	root dist;
        	index index.html;
	try_files $uri $uri/ /index.html; # 解决前端界面刷新 路由重定向404问题
        }

        location /api/video/ {
          proxy_pass http://127.0.0.1:9998/video/;
          proxy_set_header Upgrade $http_upgrade; 
        }

        location /dev-api/ {
          proxy_pass http://127.0.0.1:9000/;
        }

        client_max_body_size 10g;
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}
相关推荐
没事别瞎琢磨1 小时前
十、统一 Runner 入口——能力检测与模式回退
人工智能·node.js
没事别瞎琢磨1 小时前
八、环境隔离——构建安全的子进程环境
人工智能·node.js
没事别瞎琢磨2 小时前
六、输出捕获与截断
人工智能·node.js
没事别瞎琢磨2 小时前
七、敏感路径预检——Protected Paths
人工智能·node.js
没事别瞎琢磨3 小时前
五、进程执行——spawn、超时与进程树清理
人工智能·node.js
没事别瞎琢磨3 小时前
四、命令风险分级与审批策略
人工智能·node.js
没事别瞎琢磨3 小时前
三、配置系统——默认值与解析
人工智能·node.js
右耳朵猫AI4 小时前
Node.js周刊2026W22 | Node.js 26、Deno 2.8、Rolldown 1.0、TypeORM 1.0、Bun v1.3.14
node.js
没事别瞎琢磨4 小时前
二、类型系统——给所有概念起名字
人工智能·node.js
Java.熵减码农7 小时前
Hermes Agent 安装踩坑记录:DNS 解析失败 & Node.js 幽灵文件冲突
node.js·ai编程·hermes