Getting frames from h264 data pointer

Hi folks
I’m working on SDK for insta360 camera.
this is the repository for the sdk

The provided sdk has a live stream mode that create and write the stream into a h.h264 file.
This is the function responsible to write the data into a file:

void OnVideoData(const uint8_t* data, size_t size, int64_t timestamp, uint8_t streamType, int stream_index = 0) override {}

My question is about how to display those images stored into the pointer ‘data’ .

I tried

void OnVideoData(const uint8_t* data, size_t size, int64_t timestamp, uint8_t streamType, int stream_index = 0) override {
            // Create a cv::Mat object from the data pointer
            cv::Mat encodedImage(1, size, CV_8UC1, const_cast<uint8_t*>(data));

            imgDecoded = imdecode(encodedImage,IMREAD_ANYCOLOR);
            cv::imshow("Decoded Image", imgDecoded);
            cv::waitKey(1);

        }

but got the error terminate called after throwing an instance of 'cv::Exception' what(): OpenCV(4.2.0) ../modules/highgui/src/window.cpp:376: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'

any one could give me a hint about how display those frames.
I would like to use pure OpenCV. However, I’m open to use FFmpeg, but I just have a zero experience with FFmpeg.

thakyou

can you use any other of their callbacks?

that one is purely for encoded video, and expects you to write it to a file or send it onto the network. it’s a video stream, which requires context. there are no individual “pictures”. it’s video frames. it would require an actual video codec to decode.

there is absolutely no sense in the camera compressing this, only for you to decompress it right away.

look for an API that gives you plain video frames, as bitmaps. not bitmap files. bitmaps. uncompressed (never compressed).

you’d really want to ask them about their API.

Hi @crackwitz
Thakyou for the reply.

Well…
This is the only function that I have access to the images in terms of code.
I can set the camera to record but I cant get the images while recording process run.

I cant open a video capture because the came is no listed on my usb ports.

So, decode those frames (I belive) is the only chance that I have to get a preview image.
Do you have any other ideia? I’m desperately to get this work.

The API is worst the the sdk in terms of get images.

Update[1]: the API is based on OSC google protocol. However, the command camera.getLivePreview is no implemented.

best regards