【问题标题】:RTMP authentication not working using libavRTMP 身份验证无法使用 libav
【发布时间】:2016-03-05 00:18:23
【问题描述】:

我正在尝试使用 libav 实现 RTSP 到 RTMP 流媒体。 “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”的调用会出错。

【问题讨论】:

    标签: authentication rtmp wowza libavcodec libav


    【解决方案1】:

    由于您尝试在 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");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-30
      • 1970-01-01
      • 1970-01-01
      • 2019-04-01
      • 2012-03-31
      • 2018-02-19
      • 1970-01-01
      • 2016-04-14
      相关资源
      最近更新 更多