How do I dynamically identify the video format of the rtp stream?

Hello,

My application needs to receive and play an RTP video stream.
The format of the video stream could be either h264 or h265, but the client will not know in advance which one it is, and it does not communicate with the server at all.

I want to receive rtp stream via multicast, so I use udpsrc.
How can I set the caps of the udpsrc without knowing the video format?
For example, can I identify the video format from the RTP video stream?

Best regards,
Yamamoto

You would have to receive the packets and based on the RTP payload format for H264 and H265 you’d have to try extracting NALs from it and try to guess if this is H264 or H265.

There’s no built-in support for this in GStreamer but this is something you’d have to do on the application side.

Alternatively you could try building a pipeline with rtph264depay and rtph265depay, check which of the two leads to valid output and ignore the other (including errors from the other).

In general, this is an invalid RTP setup. RTP always requires out of band configuration for receivers to be able to interpret the streams.

I’m guessing you are not in control of the sending application?

Did you check (e.g. with wireshark) or by checking the gstreamer debug log whether the sending application uses different payload types for H264 and H265? If you’re lucky that might be enough but it will be sender/application specific then.

Hi Yamamoto, the company I work for makes a tool called mediaMin that auto-detects and decodes RTP streams, currently it handles HEVC (H.265) and a wide variety of audio codecs (EVS, AMR, G729, MELPe, etc). Video command line examples are at SigSRF_SDK/mediaTest_readme.md at master · signalogic/SigSRF_SDK · GitHub

We’re currently developing and testing H.264 auto-detect - if this is still an active project for you let us know and we can send you a test version.

FYI, we have a lot of users who, for whatever reason, do not have access to (or do not always trust) control plane (e.g. SIP) or out-of-band info, only RTP streams.

-Jeff