How to know codec from stream captured by opencv

I’m using opencv bindings for python to read a RTSP stream from a camera, do some operations and resend my frame via HTTP. I was wondering if opencv is making some kind of decoding from the stream, and if it is I can change de decoder used by the camera. But when I use cap.get(cv2.CAP_PROP_CODEC_PIXEL_FORMAT) it returns 808596553.0, and when I use cap.get(cv2.CAP_PROP_FOURCC) it returns 1668703592.0.

From these numbers, how can I know the codec being used?

I’ve seen that there is some kind of mapping as when I use cv2.VideoWriter_fourcc(*‘h264’) it returns 875967080, but how can I know what the numbers returned from my stream mean?

1 Like

I am trying to figure that out too.

Use this:

def decode_fourcc(cc):

    return "".join([chr((int(cc) >> 8 * i) & 0xFF) for i in range(4)])

It will return:

875967080.0 = h264

1668703592.0 = hevc

808596553.0 = I420

2 Likes

That’s exactly what I was looking for! Thanks!