我正在尝试使用libav实现RTSP到RTMP restreamer。"ffmpeg“命令运行正常:
ffmpeg -i "rtsp://localhost:8884/live" -vcodec copy -f rtsp "rtmp://user:password@localhost:1935/live/stream"
但是当我使用libav时,我得到了RTMP身份验证错误。以下是我尝试过的方法:
avformat_alloc_output_context2(&m_outformat, NULL, "rtsp", "rtmp://user:password@localhost:1935/live/stream");
avformat_alloc_output_context2(&m_outformat, NULL, "rtsp", "rtmp://localhost:1935/live/stream?user&password");
avformat_alloc_output_context2(&m_outformat, NULL, "rtsp", "rtmp://localhost:1935/live?user&password/stream");
avformat_alloc_output_context2(&m_outformat, NULL, "rtsp", "rtmp://localhost:1935/live/stream?username=user&password=password");
avformat_alloc_output_context2(&m_outformat, NULL, "rtsp", "rtmp://localhost:1935/live?username=user&password=password/stream");
avformat_alloc_output_context2(&m_outformat, NULL, "rtsp", "rtsp://user:password@localhost:1935/live/stream")
有人可以告诉我如何开启RTMP认证吗?
正如你在上面看到的,我们使用"rtsp“作为"format_name”,URL以"rtmp://“开头。这是因为当我们将"rtsp“保存在两者中时,"m_outformat->pb”是NULL,并且随后对"avio_open“的调用会给出错误。
发布于 2015-12-11 03:51:36
因为您正在尝试在RTMP中进行流媒体,所以您的format_name应该是flv而不是rtsp。RTMP流中的身份验证方案与RTSP流不同,您需要指定它。
以下ffmpeg命令应与RTMP身份验证方案(在Windows平台上测试)配合使用:
ffmpeg -re -i "rtsp://localhost:8884/live/myStream" -c:v copy -c:a copy -f flv "rtmp://localhost/live/myStream flashver=FMLE/3.0\20(compatible;\20FMSc/1.0) live=true pubUser=user pubPasswd=password"
如果您使用的是Linux平台,请使用以下工具进行测试:
avformat_alloc_output_context2(&m_outformat, NULL, "flv", "rtmp://user:password@localhost:1935/live/stream");
https://stackoverflow.com/questions/34014254
复制相似问题