Save video file named .mp4 with gstreamer and opencv in c++

Hi,everyone,
I use opencv and gstreamer read a video file and the use the below code
cv::VideoWriter writer(“appsrc caps=video/x-raw,format=BGR ! videoconvert ! video/x-raw,format=I420 ! x264enc ! mp4mux ! filesink location=res.mp4”,cv::CAP_GSTREAMER,capture.get(CV_CAP_PROP_FPS), (1280, 720),true);
to save a video.
But I can not open the file,because this file contains no playable videostreams.

Hi,
This should help:

Please take a look.

Thank you.
I solved it by ```
video.open(“appsrc ! autovideoconvert ! omxh265enc ! matroskamux ! filesink location=test.mkv sync=false”, 0, (double)25, cv::Size(1024, 1024), true);

But the image cv::imshow correctly but confused in the video.
Do you know why?

Hi,

Probably width and height do not match your appsrc. You may check this.