系统在测试环境测试正常,部署到正式环境发现直播预览无法观看。flv.js 报错:
VM99 flv.js:11590 [TransmuxingController] > DemuxException: type = CodecUnsupported, info = Flv: Unsupported audio codec idx: 7
VM99 flv.js:1251 Uncaught (in promise) Error: Uncaught, unspecified "error" event. (MediaError)
查看RTMP 流,可以正常播放,猜测是 nginx-http-flv-module 模块的 http-flv 取流模块 可能存在问题。于是对比测试环境和正式环境的流媒体信息。
FLV里所包含的视频编码必须是H.264
,音频编码必须是AAC
或MP3
, IE11和Edge浏览器不支持MP3音频编码,所以FLV里采用的编码最好是H.264+AAC,这个让音视频服务兼容不是问题。
正常播放的测试环境:
无法播放的正式环境:
发现推的流的语音模块不是 aac格式。
修改推流命令:
ffmpeg -f avfoundation -i "0" -vcodec h264 -acodec aac -f flv rtmp://localhost/live/test
加上红色参数。打完收工!