如何检查(控制)特定文件中的.avi格式视频文件,是否超过0KB并且可读?
问题描述:
如何检查(控制)特定文件中的.avi格式视频文件,是否超过0KB并且可读?例如如何检查(控制)特定文件中的.avi格式视频文件,是否超过0KB并且可读?
; 我有一个录像机按钮,我点击它,然后我的功能记录1分钟,并保存到文件中作为test.avi(此功能在一段时间(true){}语句)
in while(true)
另存为test.avi
另存为test2.avi 。
。
。
另存为test8.avi
所以,我怎么能检查此test.avi和所有其他videofiles,如果(test.avi不0KB和可读性),我该怎么办?
int main(void) {
while (true)
{
//Check if test.avi ready
if (test.avi is not 0KB and readable)
{
doSomeStuff01();
}
/* Check one more Time
else
{
}*/
//Check if test2.avi ready
if (test2.avi is not 0KB and readable)
{
doSomeStuff02();
}
/* Check one more Time
else
{
}*/
//Check if test3.avi ready
if (test3.avi is not 0KB and readable)
{
doSomeStuff03();
}
/* Check one more Time
else
{
}*/
//Check if test4.avi ready
if (test4.avi is not 0KB and readable)
{
doSomeStuff04();
}
/* Check one more Time
else
{
}*/
//Check if test5.avi ready
if (test5.avi is not 0KB and readable)
{
doSomeStuff05();
}
/* Check one more Time
else
{
}*/
//Check if test6.avi ready
if (test6.avi is not 0KB and readable)
{
doSomeStuff06();
}
/* Check one more Time
else
{
}*/
//Check if test7.avi ready
if (test7.avi is not 0KB and readable)
{
doSomeStuff07();
}
/* Check one more Time
else
{
}*/
//Check if test8.avi ready
if (test8.avi is not 0KB and readable)
{
doSomeStuff08();
}
/* Check one more Time
else
{
}*/
}
return(0);
}
答
这有可能是更好的解决方案,但这里有一个想法:
创建VideoCapture并检查是否可以打开.avi文件,否则捕捉异常; http://docs.opencv.org/3.0-beta/modules/videoio/doc/reading_and_writing_video.html
如果视频是0 KB =没有帧:
if(frame.empty()){ cout << "frame is empty" << endl; }