Get h264 buffer and decode it to CV MAT


I have an HW that encode video into h264 and send it as a h264 buffers , I want to know if there is a way to decode the buffers and gets the frames as appsink?

You may better explain how the h264 buffers are received from device for better advice.
From appsink, I guess you meant using gstreamer for opencv, so you would need BGR for color.

Jetsons have HW decoder (omxh264dec plugin in old L4T releases, nvv4l2decoder in recent ones) that can be used for H264 (and more) decoding, but the best path depends on your input (V4L, rtsp, appsrc, … ?) and application.
Assuming appsrc providing H264, you may try a pipeline like:

appsrc ! video/h264,width=your_width,height=your_height,framerate=your_fps/1 ! h264parse ! nvv4l2decoder ! nvvidconv ! video/x-raw,format=BGRx ! videoconvert ! video/x-raw,format=BGR ! queue ! appsink drop=1
1 Like

First of all thanks for the answer,
Another thing I really meant using gstreamer, I do have hardware that sends me a coded frame at a rate of 30 fps, the receiving is done by cb function that give my the buffer and its size . I tried running the line but it stop to decode after one frame.

You can save it to a file and check if you can run the command to decode/play the stream:

gst-launch-1.0 filesrc ! h264parse ! nvv4l2decoder ! nvoverlaysink

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.