Skip to content
Advertisement

RPi tcp video streaming with opencv and gstreamer using v4l2h264enc

I am trying to stream frames using OpenCV and Gstreamer in Python. I’m on a 64 bit Bulseye Raspberry Pi 4. This is the pipeline I am using on the Raspberry:

JavaScript

It seems to be some problem with v4l2h264enc. Enabling GST_DEBUG=4 gives me

JavaScript

These two errors look most important to me, but you can see the full log here.

Using a similar CLI pipeline the stream connects just fine (except for some encoding grayness, which isn’t the most critical to me right now).

JavaScript

With appsrc and opencv I also tried writing to a file without success.

The opencv library is compiled with Gstream support. This is what I get from cv2.getBuildInformation():

JavaScript

Any help would be most welcome!

Advertisement

Answer

As mentioned by @SeB, the BGR frames might not be supported by v4l2h264enc. And leads to this error, which videoconvert fixes:

JavaScript

But the main cause for the no source element for URI errors turned out to be the double quotes around video/x-raw and video/x-h264.

This is the final pipeline that works.

JavaScript

Also, as @SeB suggested, I also included the matroskamux instead of rtph264pay ! gdppay, since it gives better stream performance.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement