Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

what's wrong with this

// Open a video file for writing (the MP4V codec works on OS X and Windows)
cv::VideoWriter out("Motion", CV_FOURCC('m','p', '4', 'v'), FPS, cv::Size(width, height));
if(!out.isOpened()) {
std::cout <<"Error! Unable to open video file for output." << std::endl;
std::exit(-1);}

for (;;)
{ 

(timer>180) {
    // Close the old file
    //out.release();
    // Copy file
    cout << "Copying file" << endl;
    system("./copyfile.sh &");
    timer=0;
    // Move the old file to file with a timestamp suffix
    time(&stamp);
    char cmdbuf[128];
    string time_stamp=ctime(&stamp);
    time_stamp.pop_back();
    snprintf(cmdbuf,sizeof(cmdbuf),"mv bla 'bla_%s' &",time_stamp.c_str());
    if(system(cmdbuf)) {
    std::cout << "Error! Unable to execute file move" << std::endl;
    std::exit(-1);}
    system("touch bla &");
    // And open a new one
    //cv::VideoWriter out("bla", CV_FOURCC('m','p', '4', 'v'), FPS, cv::Size(width, height));
    //if(!out.isOpened()) {
    //std::cout <<"Error! Unable to open video file for output." << std::endl;
    //std::exit(-1);}
    }

The for loop is the opencv loop. As you can see i tried doing it the simple way, i also tried the stuff that is commented out, but it keeps giving me problems. Eventually it either will not create the new file, and then it can't move it because it does not exist. The shell script just reads the file. Is there something grossly incorrect i am doing?