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

}
相关推荐
麒麟而非淇淋30 分钟前
Webpack学习
前端·webpack·node.js
程序猿看视界4 小时前
npm、yarn、pnpm 最新国内镜像源设置和常见问题解决
npm·node.js·pnpm·yarn
geekrabbit4 小时前
npm切换为淘宝镜像源
linux·服务器·前端·npm·node.js·云服务器·浪浪云
Lossya4 小时前
【自动化测试】Appium Server如何安装和Appium Server安装困难的原因和解决方法以及常见的一些安装失败的错误和解决方法
自动化测试·测试工具·npm·node.js·appium·自动化
运维Z叔18 小时前
漏洞挖掘 | Selenium Grid 中的 SSRF
前端·selenium·测试工具·webpack·node.js·postman
Betray3911 天前
Postman导出报告
测试工具·node.js·postman
小于负无穷2 天前
Webpack:现代前端项目的强大打包工具
前端·javascript·webpack·typescript·node.js
sujiao6662 天前
Webpack
前端·webpack·node.js
黑客大佬2 天前
利用shuji还原webpack打包源码
服务器·前端·javascript·网络·数据库·webpack·node.js