首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用libav时RTMP身份验证不起作用

使用libav时RTMP身份验证不起作用
EN

Stack Overflow用户
提问于 2015-12-01 14:49:11
回答 1查看 1.2K关注 0票数 1

我正在尝试使用libav实现RTSP到RTMP restreamer。"ffmpeg“命令运行正常:

代码语言:javascript
运行
复制
ffmpeg -i "rtsp://localhost:8884/live" -vcodec copy -f rtsp "rtmp://user:password@localhost:1935/live/stream"

但是当我使用libav时,我得到了RTMP身份验证错误。以下是我尝试过的方法:

代码语言:javascript
运行
复制
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“的调用会给出错误。

EN

回答 1

Stack Overflow用户

发布于 2015-12-11 03:51:36

因为您正在尝试在RTMP中进行流媒体,所以您的format_name应该是flv而不是rtsp。RTMP流中的身份验证方案与RTSP流不同,您需要指定它。

以下ffmpeg命令应与RTMP身份验证方案(在Windows平台上测试)配合使用:

代码语言:javascript
运行
复制
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平台,请使用以下工具进行测试:

代码语言:javascript
运行
复制
avformat_alloc_output_context2(&m_outformat, NULL, "flv", "rtmp://user:password@localhost:1935/live/stream");
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34014254

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档