转自:http://blog.csdn.net/david412306524/article/details/7672517
#include
#include
//#include <>
#define nWidth 352
#define nHeight 288
#define FrameSize nWidth*nHeight*3/2
int _tmain(int argc, _TCHAR* argv[])
{
/*IplImage *img = cvLoadImage("D:\\workspace\\cv_yun\\DSC_1598.JPG");
cvNamedWindow("a");
cvShowImage("a",img);
cvWaitKey(0);
*/
FILE *f ;
if(!(f = fopen("目录\\foreman_cif.yuv","rb")))
{
printf("file open error!");
}
// calculate the frame num
fseek(f, 0, SEEK_END);
int frame_count = 0;
long file_size = 0;
frame_count = (int) ((int)ftell(f)/((nWidth * nHeight * 3) / 2)); // ftell 用于求文件大小
printf("frame num is %d \n", frame_count)