I am trying to read a video file using OpenCV (C++), apply a filter to each frame and write a new modified frame into an output file. The crucial parts of the code are these:
int out_format = CV_FOURCC('M','P','4','2'); // can be another one
double fps = media.get(CV_CAP_PROP_FPS),
width = media.get(CV_CAP_PROP_FRAME_WIDTH),
height = media.get(CV_CAP_PROP_FRAME_HEIGHT);
// On Linux FFMPEG is used to write videos
VideoWriter writer("./" + outputname + ".mkv", out_format, fps, Size(width, height) );
.......
.......
writer.write(newFrame); // Mat newFrame
The fact is, I am not proficient with codecs and video output formats, thus I would like to know why a file which is around 280 MB produces an output of 2 GB.
Is that a codec problem? I have tried DIVX, MPEG and others. Moreover, some output formats must go together with specific codecs.