# dashServer **Repository Path**: vesper0407/dash-server ## Basic Information - **Project Name**: dashServer - **Description**: 服务器后端 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2021-09-08 - **Last Updated**: 2021-11-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # dashServer backend for dashPlayer ## QuickStart see [egg docs][egg] for more detail. ### Development ```bash $ npm i $ npm run dev $ open http://localhost:7001/ ``` ### Deploy ```bash $ npm start $ npm stop ``` ### npm scripts - Use `npm run lint` to check code style. - Use `npm test` to run unit test. - Use `npm run autod` to auto-detect dependencies upgrade, see [autod](https://www.npmjs.com/package/autod) for more detail. [egg]: https://eggjs.org ### 本地nginx配置(不支持dash_variant) - nginx.conf位置 /usr/local/etc/nginx/nginx.conf - binary执行位置 /usr/local/bin/nginx ### 服务器配置 (支持 dash_variant) - /root/.bash_profile 配置环境变量 - nginx位置 /home/drj/nginx-1.19.2/objs - nginx.conf /home/drj/nginx-1.19.2/conf/nginx.conf ### 新增直播功能 - app/service/live/ ### 前端项目打包 - 添加静态目录/dist 直接访问 http://localhost:7001 - redirect到 /index.html 主页访问 ### dash上传 - service/upload.js ### 全景上传 - service/panorama.js ### 静态资源存放 - /staticResources/dash/first/first.mpd 存放分片视频段 以及 mpd文件 - /staticResources/live/xxx.mpd. 本地视频推流mpd rtmp://localhost:1935/myapp/xxx - /staticResources/panorama/sunset/panorama.json - /staticResources/cacheLiveVideo 存放用于推流的原视频 - /staticResources/cacheDashVideo 存放用于dash播放的平面原视频 - /staticResources/cachePanoramaVideo 全景视频 - /staticResources/processShell 处理平面视频脚本 - /staticResources/panoramaShell 处理全景视频脚本 ### router.resources('xxx') - https://eggjs.org/zh-cn/basics/router.html ### redis 存储 直播时长 - https://blog.csdn.net/realize_dream/article/details/106227622 - /usr/local/etc/redis.conf (修改conf实现后台运行) daemon yes - 启动 redis-server /usr/local/etc/redis.conf - 127.0.0.1:6379 - 查看是否正在运行 ps axu | grep redis - redis-server [/usr/local/etc/redis.conf] - service.cacheRedis ### 静态资源托管 - python -m SimpleHTTPServer 9999 (426服务器还没安装anywhere/http-server) ### 端口占用 1. lsof -i:8080 2. kill -9 [process id] ### rtmp推流 **platform-independent** - ffmpeg -re -i guitar.mp4 -vcodec libx264 -acodec aac -strict -2 -f flv rtmp://localhost:1935/myapp/guitar ### 指定nginx配置文件位置 - nginx -c /usr/local/etc/nginx/nginx.conf - nginx -s reload - nginx -s quit - nginx -s stop - /staticResources/dash/first/first.mpd 存放分片视频段 以及 mpd文件 - /staticResources/live/xxx.mpd. 本地视频推流mpd rtmp://localhost:1935/myapp/xxx - /staticResources/cacheLiveVideo 存放用于推流的原视频 - /staticResources/cacheDashVideo 存放用于dash播放的平面原视频 - /staticResources/cachePanoramaVideo 全景视频 - /staticResources/processShell 处理平面视频脚本 - /staticResources/panoramaShell 处理全景视频脚本 http://localhost:8080/live/xxx.mpd ### 开启 vr-tiled-dash-player - cd /path/to/vr-dash-tile-player - http-server --cors -p 9999 ### 杀死脚本进程 - pgrep -f 'sh ./process.sh' - kill -9 #pid ### 数据库备份 - mysqldump --databases dashVR -u root -p > ~/desktop/dashVR.sql - mysqldump -u root -p dashVR< /path/to/xx.sql ### 导入 mysql -u root -p dashVR< ~/desktop/dashvr.sql - 在此之前先create database dashVR ### tile切片以及aframe场景下rotation和position的定义 - | faceId\rotation | face0 右 | face1 左 | face2 上| face3 下| face4 前 | face5 后| | ---- | ---- | ---- |---- |---- |---- |---- | | rotation| {rx:0, ry:270, rz:0} | {rx:0, ry:90, rz:0} | {rx:90, ry:0, rz:0} | {rx:-90, ry:0, rz:0} | {rx:0, ry:0, rz:0} |{rx:0, ry:180, rz:0}| - position根据切片大小以及分片数量决定 - 右手系三维坐标 z轴伸出平面向自己延伸 - 正值顺时针 负值逆时针 以立方体中的人的视野转动为标准(默认初始视线朝着z轴负方向 也就是前方) 左上角是第一个tile - ![img.png](img.png) - ffmpeg -i "$1" -vf v360=e:c3x2:cubic:w=4320:h=2880:out_pad=0 -c:v libvpx-vp9 -crf 63 -b:v 0 -keyint_min 30 -g 30 -sc_threshold 0 -an CMP_video.mp4 - vf v360=指定格式 e:erp投影 c:立方体投影 - e: ERP 投影格式 - c: 立方体投影格式 - c3x2: c后面加3x2指的是输出立方体视频的排列方式。目前支持三种:3x2, 1x6, 6x1 - 从cmp转换回erp ffmpeg -i input.mkv -vf v360=c3x2:e:cubic:in_forder='rludfb' output.mkv - [更多详细信息](https://www.10qianwan.com/articledetail/622900.html) - w h 指定宽和高 由于我们切的格式是3x2(wxh)的所以wh也要成比例 才能切出来6个正方形 - 最后切出来6个 1440x1440的 => 要切成2x2的 每个tile 720x720 - 注意position的三维坐标 先旋转再平移 - rotation 的坐标按照 三个轴的正方向顺时针旋转 {rx,ry,rz} ### ssh自动传递密码 免手动 sshpass命令 - sshpass -p 426426 scp -r "$dirname" root@10.112.242.227:/staticResources/panorama/ ### 直播相关 Windows和Linux MacOS不一样 - [详情](https://juejin.cn/post/6953551236415258660) - 在Linux下可以使用video4linux2读取摄像头设备。 - ffmpeg在linux下支持的采集设备的种类比较多。 在操作设备之前,我们可以查看当前系统可以支持的操作设备: - ffmpeg -hide_banner -devices ```bash [root@Server1 ~]# ffmpeg -hide_banner -devices Devices: D. = Demuxing supported .E = Muxing supported -- DE fbdev Linux framebuffer D lavfi Libavfilter virtual input device DE oss OSS (Open Sound System) playback DE video4linux2,v4l2 Video4Linux2 output device ``` - ffmpeg -sources decklink (decklink 的-list_devices已经弃用 改为-sources) - 在MacOS下可以使用avfoundation读取摄像头设备。 - ffmpeg -list_devices true -f avfoundation -i "" - ```bash drj_MacBook:testVideo apple$ ffmpeg -devices -hide_banner Devices: D. = Demuxing supported .E = Muxing supported -- E audiotoolbox AudioToolbox output device D avfoundation AVFoundation input device D lavfi Libavfilter virtual input device ``` - 保证ffmpeg mp4dash mp4fragment ffprobe 安装 并且环境变量配置好 - config.default.js 下修改路径 - service下以及sh脚本文件修改路径 - 摄像头捕获直播现在只实现macos版本的 windows和linux不一样 在cameraLive.js下面自己修改 - 查看可用设备名字 ffmpeg -list_devices true -f dshow -i dummy - ffmpeg f dshow -i video="HD Pro Webcam C920" f dshow -i audio="麦克风 (HD Pro Webcam C920)"\ -r 20 -vcodec libx264 -preset ultrafast -acodec aac -ac 2 -ar 44100 -ab 128k -pix_fmt yuv420p -s 640x480\ -f flv rtmp://localhost/myapp/xxx ### 拉流 rtmp流拉本地 - ffmpeg -i rtmp://localhost:1935/myapp/guitar -vcodec h264 -f flv -acodec aac -ac 2 guitar.mp4 - 上面这个命令会将rtmp流拉到本地格式为mp4