[Ffmpeg-devel] YUV420 frames to windows bitmaps

Mark Lederman Mark
Wed May 3 19:18:30 CEST 2006


Hello all:
I?m trying to display H.264 video in win xp. For now i?d like to get started
by converting the frames into bitmaps and displaying the images. Does anyone
have some example code demonstrating this? Using the output_example program
and modifying it i was able to display images from a saved webcam file. With
the webcam stream i?m able to use the img_convert() api to get from
PIX_FMT_BGR24(video stream format) to PIX_FMT_RGB24. From there i create a
BITMAPHEADERINFO structure and then display the image using vfw (video for
windows). This works however the image displays upside down? The bitmap
structure is below

BITMAPINFOHEADER bitmapInfo;
::ZeroMemory(&bitmapInfo,sizeof(BITMAPINFOHEADER));
bitmapInfo.biSize = sizeof(BITMAPINFOHEADER);
bitmapInfo.biWidth = pCodecCtx->width;
bitmapInfo.biHeight = pCodecCtx->height;
bitmapInfo.biPlanes = 1;
bitmapInfo.biBitCount = 24;     //assume RGB24
bitmapInfo.biCompression = 0;   //0 = RGB
bitmapInfo.biSizeImage =
bitmapInfo.biWidth*bitmapInfo.biHeight*bitmapInfo.biBitCount/8;

One of the differences between the webcam file and the H.264 file is that
the frames of the H.264 file come in as PIX_FMT_YUV420P. I don?t know how to
create a YUV420 bitmap that I can display in windows. What I do is try to
convert the image to RGB24 and then display the same way as the webcam file,
however this doesn?t work. Can anyone point me in the right direction? I
know the codec is OK because I can play the file with ffplay. I?m thinking
about trying to adopt the source code from ffplay but i don?t really
understand what it?s doing. My guess is there is a simple answer to my
question. Thanks in advance.

newb






More information about the ffmpeg-devel mailing list