简体   繁体   English

使用 Opencv c++ 从视频文件中保存 10 秒的视频

[英]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.我可以保存直到我按下退出键,但想要 10 秒的视频。 I am unaware of time related Libraries in c++.我不知道 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);好的所以我发现了一个简单的技巧,我知道帧速率,使用 int x=vid.get(CAP_PROP_FPS); ie x frames are there in one second, So Use i in loop till x*10;即一秒钟内有 x 帧,所以在循环中使用 i 直到 x*10;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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