Hi hackers,
We have a quite distributed system of k8s pods that talk RTP with each other in a wild and messy way. The video payload can be H.264 or H.265 and it is becoming a burden to get the metadata sent to each node so they know what to expect.
Because of that I have started developing a small element rtpvideocodecdetect
that pretty much has the sink pad templates ~:
Pad Templates:
SINK template: 'sink'
Availability: Always
Capabilities:
application/x-rtp
media: video
SRC template: 'src'
Availability: Sometimes
Capabilities:
application/x-rtp
media: video
encoding-name: < (string)H264, (string)H265 >
clock-rate: 90000
It is sort of straight forward, it receives RTP and looks at the buffers and tries to determine what codec it is, it then sets the correct caps on the src pad. Downstream we can connect to the pad-added
signal and construct the correct depayload and processing based on the caps of the pad.
Now, for my question. It was a bit more finicky than I expected to figure out if it is H.264 or H.265 in the RTP payload. I was hoping to find some crate or library to use but have not found one yet.
I currently open-code a bunch of checking of NAL and that is surprisingly tricky. A lot of H.264 is valid H.265 … for instance I tried with the cros-codecs
crate but that told me some payload headers were parsable both as h.264 and h.265.
Is there anything in GStreamer I could lean on or use to help me out? Or does anyone know of a crate or library that can help me detect the codec? Or want to tell me of a much simpler way of achieving what I want?
Thanks for your time