FFMPEG入门

本文转自 http://blog.csdn.net/leixiaohua1020/article/details/15811977

1、分离YUV420P像素数据中的Y、U、V分量

/** 
 * Split Y, U, V planes in YUV420P file. 
 * @param url  Location of Input YUV file. 
 * @param w    Width of Input YUV file. 
 * @param h    Height of Input YUV file. 
 * @param num  Number of frames to process. 
 * 
 */  
// simplest_yuv420_split("test_yuv420p.yuv",256,256,1);
int simplest_yuv420_split(char *url, int w, int h,int num){  
    FILE *fp=fopen(url,"rb+");  
    FILE *fp1=fopen("output_420_y.y","wb+");  
    FILE *fp2=fopen("output_420_u.y","wb+");  
    FILE *fp3=fopen("output_420_v.y","wb+");  
  
    unsigned char *pic=(unsigned char *)malloc(w*h*3/2);  
  
    for(int i=0;i

从代码中可以看出,如果视频帧的宽和高分别为w和h,那么一帧YUV420P像素数据一共占用w*h*3/2 Byte的数据。其中 前 w*h Byte存储Y,接着的w*h/4 Byte存储U,最后w*h/4 Byte存储V。


你可能感兴趣的:(FFMPEG,学习)