Important: Please read the Qt Code of Conduct -

write video partition ie:10 min with opencv in qthread

  • Hi,

    I want to write videos as 10 min long or a certtain frame count and than want to change file name ie:date_time dynamically.

    I am using QThread and moving my class to it.:

    #include "videowriter.h"
    using namespace cv;
    CamVideoWriter::CamVideoWriter(QObject *parent) : QObject (parent)
        video_writer = new VideoWriter;
        video_writer->open("outcpp.avi",CV_FOURCC('M','J','P','G'),25, Size(1280,720)) ;
    CamVideoWriter::~CamVideoWriter() {
    void CamVideoWriter::FrameWriter(const cv::Mat &frame)
        if (video_writer->isOpened()) {

    How can I change the file name dynamically if a I wrote a certain amount of frame ?


  • I believe you must close video_writer and open an new one with a different name. you don't mention whether you expect to use a single QThread for all writing or spawn a new QThread each time the video file name changes.

Log in to reply