Below is my test sample to yuv2avi,for yuv420 to avi(cif), it works. Use
avilib.
#include "avilib.h"
#include "stdio.h"
/* A simple test tool of yuv2avi */
int main(int argc,char* argv[])
{
FILE* fpYUV;
char input_yuv[352*288*3/2];
avi_t* pAviHandle;
char VideoFmtYV12[4] = \ // YCrCb
{
'Y','V','1','2'
};
char VideoFmtIYUV[4] = \ // YCbCr
{
'I','Y','U','V'
};
fpYUV = fopen("test.yuv","rb");
if(!fpYUV)
{
printf("fopen failed \n");
return -1;
}
pAviHandle = AVI_open_output_file("test.avi");
if(! pAviHandle)
{
printf("avi file open failed \n");
return -1;
}
AVI_set_video(pAviHandle,352,288,25,VideoFmtIYUV);
while(!feof(fpYUV))
{
fread(input_yuv,1,352*288*3/2, fpYUV);
AVI_write_frame(pAviHandle,input_yuv,352*288*3/2);
};
// close open file
AVI_close(pAviHandle);
fclose(fpYUV);
}
阅读(926) | 评论(0) | 转发(0) |