using cv::VideoWriter and memory leak
Hi,
I using this sample to test cv::VideoWriter.And Memory leak problem happens.How can I release these memory?Is there any other way to save Mat into video file?
here is code:
void writeMP4File()
{
string videoPath = "./test.mp4";
int frameRate = 6;
Mat bmp = imread ("./test_1.png");
cv::Size frame_size(bmps[0].cols,bmps[0].rows);
std::string gst_writer = "appsrc ! video/x-raw, format=(string)BGR ! \
videoconvert ! video/x-raw, format=(string)I420 ! \
nvvideoconvert ! video/x-raw(memory:NVMM) ! \
nvv4l2h264enc ! h264parse ! matroskamux ! filesink location=" + videoPath;
cv::VideoWriter channelVideoWriter = cv::VideoWriter(gst_writer, cv::VideoWriter::fourcc('a','v','c','1'), frameRate, frame_size, true);
int frame = 0;
while(frame < 40)
{
channelVideoWriter.write(bmp);
frame++;
}
channelVideoWriter.release();}
add a comment