将bmp转换为yuv并保存 [英] Convert bmp to yuv and save
问题描述
我用这种方式将位图转换为yuv将位图保存到视频(libavcodec ffmpeg),然后像这样保存缓冲区:FILE * fp = fopen(aha.yuv,w); if(!fp)返回NULL;的fwrite(&outPic- GT;数据[0],为nbytes,1,FP);的fwrite(outBuffer,为nbytes,1,FP); FCLOSE(FP);但它只有几行。所有.yuv文件都是灰色的。我确定inbuffer指向输入BGR32数据。那么哪里错了?是保存outBuffer的方法吗?
http:/ /stackoverflow.com/questions/1359620/save-bitmap-to-video-libavcodec-ffmpeg [ ^ ]
I use this way to convert bitmap to yuv Save bitmap to video (libavcodec ffmpeg) and then save the buffer 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); but it has only several lines.All most all of the .yuv file is gray. I am sure the inbuffer points to the input BGR32 data.So where is wrong? is The way to save the outBuffer right?
http://stackoverflow.com/questions/1359620/save-bitmap-to-video-libavcodec-ffmpeg[^]
推荐答案
1。请使用这样的代码标签格式化您的来源
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.你应该在二进制模式下使用fopen()
3.看不到你写的Fileheader或Bitmap-Header,只有数据
4.有几种方法可以存储YUV -Images,请参阅:
YUVIT - 开源转换器到YUV色彩空间
https://github.com/stunpix/yuvit
yuv:平面格式
yuyv:打包格式
uyvy:打包格式
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
这篇关于将bmp转换为yuv并保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!