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?
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
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.