Red5 配置RTMPT

时间:2021-11-07 14:57:48

在网上找了挺长时间,终于把RTMPT的问题解决了。

我要做的项目需要实现这样的流程:

  1. 流服务器输出RTMP码流
  2. Red5接收码流该RTMP码流
  3. Red5把RTMP码流转成RTMPT流,并向客户端广播

当然我在这里面做的工作很少,仅仅几个配置而已。

配置Red5的RTMPT

总结邮件列表内容,配置Red5的RTMPT有两种方式:

  1. 配置jee-container.xml 增加connector。这会产生一个独立的RTMPT服务。据说这中配置方式比较耗费资源,没尝试。
  2. 配置你自己的应用目录中的web.xml,增加sevelet。

我配置成功主要是根据Mondain的邮件回复,内容如下:

  1. The RTMPT that is in the jee-container.xml is for a standalone internal service. This is not the way I recommend RTMPT usage; I suggest using the RTMPT servlet in your application instance instead. It saves resources, a port mapping, and probably other things as well. Look at the web.xml attached to see how to enable the RTMPT servlet.
  2. You have to change the port to the default which is 5080, unless you updated your red5.properties file with another port. The 8088 port is the default for standalone RTMPT only, which is also configurable in the red5.properties file.

方法(第二种方式)

第二种配置方法有下面几点需要注意:

  1. 保留root应用,否则无法正常使用RTMPT。
  2. 修改你的应用的web.xml文件,增加:
    <servlet>
    <servlet-name>rtmpt</servlet-name>
    <servlet-class>org.red5.server.net.rtmpt.RTMPTServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>rtmpt</servlet-name>
    <url-pattern>/fcs/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>rtmpt</servlet-name>
    <url-pattern>/open/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>rtmpt</servlet-name>
    <url-pattern>/close/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>rtmpt</servlet-name>
    <url-pattern>/send/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>rtmpt</servlet-name>
    <url-pattern>/idle/*</url-pattern>
    </servlet-mapping>

  3. 修改%RED5%/conf/red5.properties文件
    我是这样改的:
    http.port = 80
    rtmpt.prot = 5080
    据我自己的理解,Red5对这两个端口做了映射。因此来自客户端的RTMPT请求是针对80端口的,这一点我抓包确认过。

大概就这样。