简体   繁体   中英

Save Video of 10seconds from a video file using Opencv c++

I am able to save till i press escape, But want video of 10 seconds. I am unaware of time related Libraries in c++. Thank you!

    while(true){
            Mat oneFrame;
            bool check=vid.read(oneFrame);
            if(!check){
                cout<<"something went wrong\n";
                cin.get();
                break;
            }
            vW.write(oneFrame);
            imshow(window_name, oneFrame);
            if(waitKey(10)==27){
                cout<<"Exiting because ESC is pressed\n";
                break;
            }

Okay So i just found a simple trick, I know the frame rate, Using int x=vid.get(CAP_PROP_FPS); ie x frames are there in one second, So Use i in loop till x*10;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM