I’m having trouble recreating what @Honey_Patouceul describe above: taking a single GStreamer pipeline, breaking it up into filesink/filesrc instead of appsink/appsrc.
Here’s my pipeline that captures from a camera and saves it as a .mkv file:
gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM), width=(int)2592, height=(int)1944, format=(string)NV12, framerate=(fraction)30/1' ! nvvidconv ! 'video/x-raw, format=(string)BGRx' ! videoconvert ! 'video/x-raw, format=(string)BGR' ! videoconvert ! 'video/x-raw, format=(string)BGRx' ! videoconvert !'video/x-raw, format=(string)I420' ! omxh264enc ! matroskamux ! filesink location=video1.mkv
I tried to make it as close to the “split” pipelines in OpenCV as possible (converting to BGR and back). It works, records the camera fine – all good. I then split it up into the following two pipelines:
Camera Pipeline
gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM), width=(int)2592, height=(int)1944, format=(string)NV12, framerate=(fraction)30/1' ! nvvidconv ! 'video/x-raw, format=(string)BGRx' ! videoconvert ! 'video/x-raw, format=(string)BGR' ! filesink location=video.raw
Encode Pipeline
gst-launch-1.0 filesrc location=video.raw ! 'video/x-raw, format=(string)BGR, width=(int)2592, height=(int)1944, framerate=(fraction)30/1' ! videoconvert ! 'video/x-raw, format=(string)BGRx' ! videoconvert ! 'video/x-raw, format=(string)I420' ! omxh264enc ! matroskamux ! filesink location=video.mkv
The Camera Pipeline runs with no errors, but I see this repeated warning when reading from the file:
WARNING: from element /GstPipeline:pipeline0/GstVideoConvert:videoconvert0: Internal GStreamer error: code not implemented. Please file a bug at http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer.
Additional debug info:
gstvideofilter.c(293): gst_video_filter_transform (): /GstPipeline:pipeline0/GstVideoConvert:videoconvert0:
invalid video buffer received
Any help would be appreciated.
I’m doing this exercise because I can’t seem to record the camera stream correctly from OpenCV using gstreamer in VideoWriter. The following code will save a .mkv that i can playback but the doesn’t look right (screen tearing (?) on every row).
gst_dst = "appsrc ! videoconvert ! omxh264enc ! matroskamux ! filesink location=test.mkv "
writer = cv2.VideoWriter(gst_dst, cv2.CAP_GSTREAMER, 0, 20.0, (1280, 720), True)
Note: I can preview the frames fine, and I’ve confirmed it’s in RGB format with the right shape. I can also encode fine using FFMPEG, but I prefer to use gstreamer if possible.