c++ - Opening a GStreamer pipeline from OpenCV with VideoWriter -


i capturing , processing video frames opencv, , write them h265 video file. struggling proper gstreamer pipeline work opencv.

gstreamer works fine itself. in particular, able run command, encodes video (thanks gpu acceleration) , saves mkv file:

gst-launch-1.0 videotestsrc num-buffers=90 ! 'video/x-raw, format=(string)i420, width=(int)640, height=(int)480' ! omxh265enc ! matroskamux ! filesink location=test.mkv 

now same thing within opencv application. code like:

mat img_vid = mat(1024, 1024, cv_8uc3);  videowriter video; video.open("appsrc ! autovideoconvert ! omxh265enc ! matroskamux ! filesink location=test.mkv", 0, (double)25, cv::size(1024, 1024), true);  if (!video.isopened()) {    printf("can't create writer\n");    return -1; }  while ( ... ) {     // capture frame img_vid => works fine     video.write(img_vid);     ... } 

at first sight, seems work, creates file named "appsrc ! autovideoconvert ! omxh265enc ! matroskamux ! filesink location=test.mkv" , fills uncompressed video frames, completely ignoring fact gstreamer pipeline.

i have tried other pipelines, result in variety of errors:

video.open("appsrc ! autovideoconvert ! omxh264enc ! 'video/x-h264, streamformat=(string)byte-stream' ! h264parse ! qtmux ! filesink location=test.mp4 -e", 0, (double)25, cv::size(1024, 1024), true); 

which results in:

(test:5533): gstreamer-critical **: gst_element_make_from_uri: assertion 'gst_uri_is_valid (uri)' failed opencv error: unspecified error (gstreamer: cannot find appsrc in manual pipeline ) in cvvideowriter_gstreamer::open, file /home/ubuntu/opencv/modules/videoio/src/cap_gstreamer.cpp, line 1363 videoio(cvcreatevideowriter_gstreamer(filename, fourcc, fps, framesize, is_color)): raised opencv exception:

/home/ubuntu/opencv/modules/videoio/src/cap_gstreamer.cpp:1363: error: (-2) gstreamer: cannot find appsrc in manual pipeline in function cvvideowriter_gstreamer::open

i tried simple:

video.open("appsrc ! autovideosink", 0, (double)25, cv::size(1024, 1024), true); 

which yields:

gstreamer plugin: embedded video playback halted; module appsrc0 reported: internal data flow error.

i using opencv 3.1 gstreamer support. hardware jetson tx1 l4t 24.2.1.

i encountered similar problem before. since pipe/file name ends .mkv, opencv interprets video file instead of pipe.

you can try ending dummy spacing after mkv

video.open("appsrc ! autovideoconvert ! omxh265enc ! matroskamux ! filesink location=test.mkv ", 0, (double)25, cv::size(1024, 1024), true); 

or dummy property like

video.open("appsrc ! autovideoconvert ! omxh265enc ! matroskamux ! filesink location=test.mkv sync=false", 0, (double)25, cv::size(1024, 1024), true); 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -