OpenCV 4.2.0 C++ - H264 Encoding

asked 2020-03-24 05:41:05 -0600

pmag gravatar image

updated 2020-03-24 07:49:01 -0600

supra56 gravatar image

Hello,

Currently, i'm using OpenCV 4.2 C++ in order to encode and stream outputs from a Allied Vision Manta camera.

I already can grabe a frame, compress with MJPEG and the stream to other pipeline using OpenCV and GStreamer.

However, i need to try with H.264 (and later with H.265) but it's not working. The pipelines created are these in VideoWriter function are the follow:

1 - "appsrc ! queue ! videoconvert ! x264enc ! rtph264pay ! udpsink host=127.0.0.1 port=5015";

2 - "appsrc ! autovideoconvert ! videoconvert ! x264enc ! rtph264pay ! udpsink host=127.0.0.1 port=5015";

With the 1st pipe, i get:

"  [ WARN:0] global /opt/opencv/modules/videoio/src/cap_gstreamer.cpp (1759) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module x264enc0 reported: Can not initialize x264 encoder.
  [ WARN:0] global /opt/opencv/modules/videoio/src/cap_gstreamer.cpp (1665) writeFrame OpenCV | GStreamer warning: Error pushing buffer to GStreamer pipeline "

With the 2nd pipe, I get:

"libva info: VA-API version 0.39.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/vmwgfx_drv_video.so
libva info: va_openDriver() returns -1 "

The others arguments are :

 " cv::CAP_GSTREAMER, 0, 5,  Size(1080, 720), true "
The input pixel format is the YUV444p, convert into Mat with - " Mat( Size(1080, 720) , CV_8UC3, pBuffer, Mat::AUTO_STEP "
The receiver is done with " udpsrc port=5015 ! application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264,framerate=15/1 ! rtph264depay ! decodebin ! videoconvert ! appsink ".

One detail that i don't know if it's important or not, i'm doing this in the VirtualBox.

edit retag flag offensive close merge delete