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;
    #    }
    #}

}
相关推荐
ID346107442011 小时前
【课程设计】基于Spring Boot+Vue的校园共享无人机服务系统设计与实现-计算机毕设 附源码44219
javascript·vue.js·spring boot·python·node.js·php·课程设计
敲敲敲敲暴你脑袋17 小时前
地图瓦片批量改色来啦!
node.js·gis·数据可视化
太子釢1 天前
AI 开发个人记账 App(服务端篇)
node.js·ai编程
用户64340495148512 天前
Elpis 项目构建工具与前端基建实践总结
node.js
FungLeo2 天前
成为全栈·Node 后端篇·后端测试策略:单元、集成与测试数据库
单元测试·node.js·集成测试·测试策略·成为全栈·测试数据库
FungLeo2 天前
成为全栈·Node 后端篇·评论内容安全:敏感词过滤、三态审核与级联删除
node.js·敏感词过滤·成为全栈·评论内容安全·评论审核·级联删除
FungLeo2 天前
成为全栈·Node 后端篇·阅读量防刷:去重、冷却与计数写分离
node.js·读写分离·数据去重·接口防刷·成为全栈·数据冷却
脉动数据行情13 天前
Node.js WebSocket 实现贵金属实时行情监听 伦敦金 / 伦敦银自动重连方案
websocket·node.js·vim
不老刘3 天前
一行命令解决 Node.js 版本兼容问题:`--openssl-legacy-provider` 深度解析
node.js
万敏3 天前
Vue3 全栈实战:第一阶段复盘(第1-8周)
vue.js·node.js·全栈