opencv build with gstreamer can't initial cv2.VideoWriter

I use command below to build opencv tag:3.4.3 with gstreamer.

sudo cmake -D CMAKE_BUILD_TYPE=RELEASE -D PYTHON_EXECUTABLE=/usr/bin/python3.6 -D OPENCV_PYTHON3_INSTALL_PATH=/usr/local/lib/python3.6/dist-packages -D BUILD_OPENCV_PYTHON3=YES -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_CUDA=ON -D CUDA_ARCH_BIN=“6.2” -D CUDA_ARCH_PTX="" -D ENABLE_FAST_MATH=ON -D CUDA_FAST_MATH=ON -D WITH_CUBLAS=ON -D WITH_LIBV4L=ON -D WITH_GSTREAMER=ON -D WITH_GSTREAMER_0_10=OFF -D WITH_QT=ON -D WITH_OPENGL=ON -D ENABLE_NEON=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF …

Successfully. After that I tried to read rtsp stream with cv2.VideoCapture and worked.

import cv2
vid_cap = cv2.VideoCapture(“rtspsrc location=rtsp://10.30.4.14/0 latency=200 ! rtph264depay ! h264parse ! omxh264dec ! nvvidconv ! video/x-raw, width=(int)1024, height=(int)768, format=(string)BGRx ! videoconvert ! appsink”, cv2.CAP_GSTREAMER)
[ WARN:0] VIDEOIO(createGStreamerCapture(filename)): trying …

NvMMLiteOpen : Block : BlockType = 261
TVMR: NvMMLiteTVMRDecBlockOpen: 7647: NvMMLiteBlockOpen
NvMMLiteBlockCreate : Block : BlockType = 261
TVMR: cbBeginSequence: 1179: BeginSequence 1024x768, bVPR = 0
TVMR: LowCorner Frequency = 100000
TVMR: cbBeginSequence: 1529: DecodeBuffers = 6, pnvsi->eCodec = 4, codec = 0
TVMR: cbBeginSequence: 1600: Display Resolution : (1024x768)
TVMR: cbBeginSequence: 1601: Display Aspect Ratio : (1024x768)
TVMR: cbBeginSequence: 1669: ColorFormat : 5
TVMR: cbBeginSequence:1683 ColorSpace = NvColorSpace_YCbCr601
TVMR: cbBeginSequence: 1809: SurfaceLayout = 3
TVMR: cbBeginSequence: 1902: NumOfSurfaces = 13, InteraceStream = 0, InterlaceEnabled = 0, bSecure = 0, MVC = 0 Semiplanar = 1, bReinit = 1, BitDepthForSurface = 8 LumaBitDepth = 8, ChromaBitDepth = 8, ChromaFormat = 5
TVMR: cbBeginSequence: 1904: BeginSequence ColorPrimaries = 2, TransferCharacteristics = 2, MatrixCoefficients = 2
Allocating new output: 1024x768 (x 13), ThumbnailMode = 0
OPENMAX: HandleNewStreamFormat: 3464: Send OMX_EventPortSettingsChanged : nFrameWidth = 1024, nFrameHeight = 768
reference in DPB was never decoded
[ WARN:0] VIDEOIO(createGStreamerCapture(filename)): result=0xfc1fc0 isOpened=1 …

But when I try cv2.VideoWriter to write video, it just blocked and with no response.

cv2.VideoWriter(“appsrc ! autovideoconvert ! omxh264enc ! matroskamux ! filesink location=test.mp4 sync=false”, cv2.CAP_GSTREAMER, 0, 24, (300, 300))
[ WARN:0] VIDEOIO(cvCreateVideoWriter_GStreamer (filename.c_str(), fourcc, fps, frameSize, isColor)): trying …

Did I do anything wrong?Any advice is grateful.

We didn’t have many experience of using opencv’s videowriter to encode a file.
Could you simplify the usecase for debug? For example, just use gstreamer with simple usb cam as appsrc.