1. Please format your Source with code tag like this
FILE* fp=fopen("aha.yuv","w");
if(!fp) return NULL;
fwrite(outPic->data[0],nbytes,1,fp);
fwrite(outBuffer,nbytes,1,fp);
fclose(fp);
2. You should use fopen() in binary mode
3. Can´t see writing you Fileheader or Bitmap-Header, only Data
4. There are several ways to store YUV-Images, see:
YUVIT - open source convertor to YUV colorspace
https://github.com/stunpix/yuvit
yuv : Planar format
yuyv : Packed format
uyvy : Packed format