Closed forest-yang closed 5 years ago
flv.js只支持H.264视频编码和AAC/MP3音频编码,请确认摄像头推流的音视频编码格式
我的机器是MAC OS,设备列表输出如下: [AVFoundation input device @ 0x7f84c591e9c0] AVFoundation video devices: [AVFoundation input device @ 0x7f84c591e9c0] [0] FaceTime HD Camera [AVFoundation input device @ 0x7f84c591e9c0] [1] Capture screen 0 [AVFoundation input device @ 0x7f84c591e9c0] [2] Capture screen 1 [AVFoundation input device @ 0x7f84c591e9c0] AVFoundation audio devices: [AVFoundation input device @ 0x7f84c591e9c0] [0] Built-in Microphone
我换了个命令从摄像头获取视频:
ffmpeg -f avfoundation -framerate 30 -i 0 -c:v libx264 -r 30 -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -preset veryslow -f flv rtmp://192.168.31.132:1935/myapp/test
同样,推流命令可以执行,VLC观看成功,但是flv.js就是不成功。nginx日志报错:
flv live: app args MUST be specified, client: 192.168.31.67, server: localhost, request: "GET /live.html HTTP/1.1", host: "192.168.31.132:8080"
请问可能是哪里的错误呢?是HTML里的访问链接错误还是nginx.conf里的live小节配置错误?
那跟nginx-http-flv-module没关系,我在Mac上也从来没成功过,用Windows和Linux上的Chrome和Firefox都测试过,没问题。flv.js需要MSE的支持:https://github.com/bilibili/flv.js#overview Apple对MSE(故意)支持不太好!
非常感谢提示(和nginx-http-flv-module没关系),是我配置的原因,我直接打开html页面(里面包含访问流的链接,不通过nginx web服务器),可以访问了。
当然还有个小问题,为什么直播页面html放在nginx里不行,我自己再琢磨下。
你再看看吧,祝好运! 准确点说是在Mac上的Safari测试从来没成功过,Mac的Firefox是可以的,README里的截图用的就是Mac上的Firefox截图。很奇怪的是用 http://html5test.com/ 查看Safari是支持MSE的,但是确实从来没成功过。
我测试使用nginx + nginx-http-flv-module + flv.js直接视频,报错(使用VLC播放正常):
nginx error.log错误日志:
关键配置说明:
nginx配置
推流命令:
使用VLC播放链接:
html代码片段:
请问是哪个环节出了问题?多谢! 环境: Nginx: 1.15.10 nginx-http-flv-module: 1.2.6 Chrome: 73