我已经在AWS上设置了Wowza流引擎,应用程序名称为"live"。我已经打开了AWS上Wowza接收和重新传输视频流所需的所有端口。
我正在从局域网的NVR中获取视频流,并使用FFMPEG将来自Ubuntu机器的视频流发布到Wowza服务器上。
ffmpeg -v debug -i "rtsp://888888:888888@192.168.1.5:554/cam/realmonitor?channel=1&subtype=1" -acodec copy -vcodec copy -sn -f flv "rtmp://xx.xx.xx.xx:1935/live/channel1 live=true pubUser=un pubPasswd=pw"
在终端上大约60秒后出现以下错误。
Successfully parsed a group of options.
Opening an output file: rtmp://xx.xx.xx.xx:1935/live/channel1 live=true pubUser=un pubPasswd=pw.
Parsing...
Parsed protocol: 0
Parsed host : xx.xx.xx.xx
Parsed app : live
RTMP_Connect0, failed to connect socket. 110 (Connection timed out)
rtmp://xx.xx.xx.xx:1935/live/channel1 live=true pubUser=un pubPasswd=pw: Unknown error occurred
所以,我检查了Wowza服务器日志,寻找任何线索,我发现了这个。
2016-09-27 08:22:31 UTC comment server INFO 200 - MediaCasterStreamValidator.init[live/_definst_]: Started
2016-09-27 08:22:31 UTC comment server INFO 200 - ModuleCoreSecurity.onAppStart[live/_definst_]: Publish: AllowedEncoders: securityPublishValidEncoders:Wirecast/|FME/|FMLE/|Wowza GoCoder*|Lavf/|UA Teradek/|KulaByte/|VidBlaster/|XSplit/|PESA
2016-09-27 08:22:31 UTC comment server INFO 200 - ModuleCoreSecurity.onAppStart[live/_definst_]: Publish: block duplicate stream names : false
2016-09-27 08:22:31 UTC comment server INFO 200 - ModuleCoreSecurity.onAppStart[live/_definst_]: Publish: RTMP Authorization: password file:/usr/local/WowzaStreamingEngine/conf/publish.password
2016-09-27 08:22:31 UTC comment server INFO 200 - ModuleCoreSecurity.onAppStart[live/_definst_]: Play: SecureConnection: securityPlayRequireSecureConnection:false
2016-09-27 08:22:31 UTC comment server INFO 200 - ModuleCoreSecurity.onAppStart[live/_definst_]: Play: securitySecureTokenVersion property is missing, using SecureToken Version 1, play security enabled for RTMP only
2016-09-27 08:22:31 UTC app-start application INFO 200 _definst_ live/_definst_
2016-09-27 08:22:31 UTC connect-pending session INFO 100 <incomming IP> - _defaultVHost_ live _definst_ 2.975 [any] 1935 rtmp://xx.xx.xx.xx:1935/live <incomming IP>` rtmp - unknown 1873157588 3178 3073 - - - - - - - - - - - - - rtmp://xx.xx.xx.xx:1935/live -
2016-09-27 08:22:31 UTC connect session INFO 200 <incomming IP> - _defaultVHost_ live _definst_ 2.975 [any] 1935 rtmp://xx.xx.xx.xx:1935/live <incomming IP> rtmp - unknown 1873157588 3178 3073 - - - - - - - - - - - - - rtmp://xx.xx.xx.xx:1935/live -
2016-09-27 08:22:32 UTC create stream INFO 200 - - _defaultVHost_ live _definst_ 0.0 [any] 1935 rtmp://xx.xx.xx.xx:1935/live <incomming IP> rtmp - unknown 1873157588 3297 3565 1 0 0 0 - - - - - - rtmp://xx.xx.xx.xx:1935/live rtmp://xx.xx.xx.xx:1935/live - rtmp://xx.xx.xx.xx:1935/live -
2016-09-27 08:22:33 UTC destroy stream INFO 200 - - _defaultVHost_ live _definst_ 1.644 [any] 1935 rtmp://xx.xx.xx.xx:1935/live <incomming IP> rtmp - unknown 1873157588 3347 3796 1 0 0 0 - - - - - - rtmp://xx.xx.xx.xx:1935/live rtmp://xx.xx.xx.xx:1935/live - rtmp://xx.xx.xx.xx:1935/live -
2016-09-27 08:22:33 UTC disconnect session INFO 200 1873157588 - _defaultVHost_ live _definst_ 5.198 [any] 1935 rtmp://xx.xx.xx.xx:1935/live <incomming IP> rtmp - unknown 1873157588 3347 3796 - - - - - - - - - - - - - rtmp://xx.xx.xx.xx:1935/live -
2016-09-27 08:23:34 UTC app-stop application INFO 200 _definst_ live/_definst_
所以基本上服务器身份验证是正确的,但服务器启动流并立即停止。
谁能给我一些指针来寻找这个错误?
看起来您的ffmpeg命令没有发送用户代理字符串(访问日志中的c-user-agent)。这有助于您的Wowza服务器识别哪些RTMP连接是有效的发布者。
下面一行标识了在Wowza服务器中配置的有效代理字符串:
2016-09-27 08:22:31 UTC comment server INFO 200 - ModuleCoreSecurity.onAppStart[live/_definst_]: Publish: AllowedEncoders: securityPublishValidEncoders:Wirecast/|FME/|FMLE/|Wowza GoCoder*|Lavf/|UA Teradek/|KulaByte/|VidBlaster/|XSplit/|PESA
但是您的ffmpeg命令正在根据日志发送unknown
代理字符串。尝试在ffmpeg命令的输出URL中使用以下命令:
"rtmp://localhost/live/myStream flashver=FMLE/3.020(compatible;20FMSc/1.0) live=true pubUser=myuser pubPasswd=mypassword"
它应该传递一个代理字符串,该字符串与Wowza服务器的有效编码器之一相匹配。