Re: Converting YUY2 format video to AVI
- From: bharath_r <bharath.0523@xxxxxxxxx>
- Date: Thu, 21 Feb 2008 04:47:30 -0800 (PST)
On Feb 21, 3:50 pm, Paul <nos...@xxxxxxxxxx> wrote:
bharath_r wrote:
Hi,
I have a video capture card that captures videos in H.264 format. I am
using the api that comes with the card to decode the videos frame by
fram into YUV2 format and then using the video for windows library
functions to compress it into avi format. The compression works fine,
except that the resulting video has very poor color reproduction. Its
like watching a negative print. Can anyone help me in solving this?
Thanks
Bharath
So you know, somewhere along the way, that one of your assumptions
about the color model or pixel mode, is wrong. Somehow, you need a
way to verify the content of the movie, through each stage of your
process.
Could you start, by converting VGZ to uncompressed format. So at least
the data would be easier to examine ? Then go from uncompressed to AVI
and check the color output again.
And for the movie, stick a static image in front of the camera, with
standard colors of some sort on the target. Sort of like this
(just the concept, not the whole chart). You need some way to verify
the transformation of the data, stage by stage.
http://en.wikipedia.org/wiki/SMPTE_color_bars
Paul
Hi Paul,
One thing I am certain about is that the decoding works fine. Since i
am displaying each decoded frame i can tell you that the resulting
YUY2 frame has no color reproduction problem. The problem is while
compressing to avi. But i am not able to find what setting is causing
the problem. I am very new to this and i'm not able to figure out what
is wrong. Here is the code what i am doing
#define YUY2 mmioFOURCC('Y','U','Y','2')
#define XVID mmioFOURCC('X','V','I','D')
hicc = ICOpen(ICTYPE_VIDEO, XVID, ICMODE_COMPRESS);
// Get width and height of YUV source image
Width = 320;
Height = 240;
// Set the capture's YUV format
pYUVFmt = (LPBITMAPINFOHEADER)malloc(sizeof(BITMAPINFOHEADER));
memset(pYUVFmt, 0, sizeof(BITMAPINFOHEADER));
pYUVFmt->biSize = sizeof( BITMAPINFOHEADER);
pYUVFmt->biWidth = Width;
pYUVFmt->biHeight = Height;
pYUVFmt->biPlanes = 1;
pYUVFmt->biBitCount = 24;
pYUVFmt->biCompression = YUY2;
lFmtLength = ICCompressGetFormat(hicc, pYUVFmt, NULL);
pXVIDFmt = (LPBITMAPINFOHEADER)malloc(abs(lFmtLength));
ICCompressGetFormat(hicc, pYUVFmt, pXVIDFmt);
// Init AVIFile functions
AVIFileInit();
// Delete the previously captured file
OpenFile("c:\\capture.avi", &of, OF_DELETE);
// Create and open the the capture file
AVIFileOpen(&pfile, "c:\\capture.avi", OF_CREATE | OF_WRITE |
OF_SHARE_DENY_NONE, NULL);
// Set the AVI stream information
sivideo.fccType = streamtypeVIDEO;
sivideo.fccHandler = XVID;
sivideo.dwFlags = 0;
sivideo.dwCaps = 0;
sivideo.wPriority = 0;
sivideo.wLanguage = 0;
if ((iStandard == PAL_STANDARD) ||
(iStandard == SECAM_STANDARD))
{
// PAL/SECAM 25 fps
sivideo.dwScale = 1;
sivideo.dwRate = 25;
}
else
{
// NTSC 29.97 fps
sivideo.dwScale = 1001;
sivideo.dwRate = 30000;
}
sivideo.dwStart = 0;
sivideo.dwLength = 0;
sivideo.dwInitialFrames = 0;
sivideo.dwSuggestedBufferSize = 0;
sivideo.dwQuality = (DWORD)-1;
sivideo.dwSampleSize = 0;
sivideo.rcFrame.left = 0;
sivideo.rcFrame.top = 0;
sivideo.rcFrame.right = 0;
sivideo.rcFrame.bottom = 0;
sivideo.dwEditCount = 0;
sivideo.dwFormatChangeCount = 0;
sivideo.szName[0] = 0;
// Create the AVI stream
AVIFileCreateStream(pfile, &pavivideo, &sivideo);
// Set the XVID format in the AVI stream
AVIStreamSetFormat(pavivideo, 0, pXVIDFmt, lFmtLength);
// Get the current frame index in the AVI stream (0)
lIndex = AVIStreamLength(pavivideo);
// Allocate the XVID compressed data buffer
pXVIDBuffer = malloc(Width * Height * 2);
dwNextIndexCount = 0;
dwPrevIndexCount = 0;
prevYUVBuff = NULL;
prevYUVFmt = NULL;
DWORD res = ICCompressBegin(hicc,pXVIDFmt,pYUVFmt);
if(res != ICERR_OK)
{
return;
}
ICCompress(hicc,
ICCOMPRESS_KEYFRAME,
pXVIDFmt,
pXVIDBuffer,
pYUVFmt,
buff,
&dwCkID,
&dwFlags,
lIndex,
0,
7500, // Quality * 100
prevYUVFmt,
prevYUVBuff);
// Save this compressed frame in the AVI stream
AVIStreamWrite(pavivideo,
lIndex++,
1,
pXVIDBuffer,
pXVIDFmt->biSizeImage,
AVIIF_KEYFRAME,
NULL,
NULL);
.
- Follow-Ups:
- Re: Converting YUY2 format video to AVI
- From: Paul
- Re: Converting YUY2 format video to AVI
- From: Ken Maltby
- Re: Converting YUY2 format video to AVI
- References:
- Converting YUY2 format video to AVI
- From: bharath_r
- Re: Converting YUY2 format video to AVI
- From: Paul
- Converting YUY2 format video to AVI
- Prev by Date: Adjusting audio with Premiere Pro 1.5
- Next by Date: Re: Bit rate for "temporary storage" of 8mm
- Previous by thread: Re: Converting YUY2 format video to AVI
- Next by thread: Re: Converting YUY2 format video to AVI
- Index(es):
Relevant Pages
|