streamingresolutionred5

How do I detect live stream resolution in Red5?


How do I detect live stream resolution in Red5? I do override streamPublishStart(IBroadcastStream stream) where (correct me if I'm wrong) stream starts:

public void streamPublishStart(IBroadcastStream stream) {
        IConnection connection = Red5.getConnectionLocal();
    log.info("W3C x-category:stream x-event:publish c-ip:{} x-sname:{} x-name:{}",
            new Object[] { connection != null ? connection.getRemoteAddress() : "0.0.0.0", stream.getName(), stream.getPublishedName() });

}

Where I can access stream object. How do I check it's resoluton? I did tried stream.getMetaData().getHeader() but it gives me Header is null error. I have googled problem and I can't find any solution.


Solution

  • You will need to decode the incoming data to get the information that you require. Red5 does not decode the streams out-of-the-box. The only information we pull is the AVC and AAC coded "config" data and I wouldn't call that "decoding" per-se. The config will only give you a minimal amount of information about AVC/h.264 or AAC media. You can see the configuration information in these two classes:

    https://github.com/Red5/red5-io/blob/master/src/main/java/org/red5/codec/AVCVideo.java

    https://github.com/Red5/red5-io/blob/master/src/main/java/org/red5/codec/AACAudio.java

    The "stream" shown in the method signature you've posted will be a ClientBroadcastStream in most if not all cases. You can review the incoming audio and video data by extending this class or creating your own listener.

    Lastly, the getMetaData() method will only return something of value to you if the broadcaster or the file source has provided the meta data content; in addition, the "Header" will not contain the bitrate.

    MetaData class: https://github.com/Red5/red5-io/blob/master/src/main/java/org/red5/io/flv/meta/MetaData.java

    Header class: https://github.com/Red5/red5-server-common/blob/master/src/main/java/org/red5/server/net/rtmp/message/Header.java