Hello,
I am developing a PCI capture driver, and I use “avshws” as sample to develp the driver.
I can capture AVI with H.264 codec by AMCAP, and the avi file can play well.
My problem is as following:
In my video packets, there is only one key frame in every 90 frames. However, the frames in the captured AVI file are all labeled as key frame.
I have set following frame information before the data is sent by capture pin:
PKSSTREAM_HEADER pHeader = pStreamPointer->StreamHeader;
…
llClockTime = m_Clock->GetCorrelatedTime(&llClockTime);
pHeader->PresentationTime.Time = llClockTime;
pHeader->Duration = -liTimeout.QuadPart;
pHeader->PresentationTime.Numerator = pHeader->PresentationTime.Denominator = 1;
pHeader->OptionsFlags = KSSTREAM_HEADER_OPTIONSF_TIMEVALID |
KSSTREAM_HEADER_OPTIONSF_DURATIONVALID;
if(pHeader->Size >= sizeof(KSSTREAM_HEADER) + sizeof(KS_FRAME_INFO)){
PKS_FRAME_INFO FrameInfo = reinterpret_cast <pks_frame_info>(pHeader + 1);
FrameInfo->ExtendedHeaderSize = sizeof (KS_FRAME_INFO);
FrameInfo->PictureNumber = m_nFrameNum;
FrameInfo->DropCount = 0;
switch(nFrameType)
{
case 0:
FrameInfo->dwFrameFlags = KS_VIDEO_FLAG_I_FRAME;
break;
case 3:
FrameInfo->dwFrameFlags = KS_VIDEO_FLAG_P_FRAME;
}
}
But it seems no effect for the AVI file. All the frames in AVI file are still labeled as key frame.
The capture pin video data range is as below:
KS_DATARANGE_VIDEO
FormatH264_Capture = {
//
// KSDATARANGE
//
{
sizeof (KS_DATARANGE_VIDEO), // FormatSize
0, // Flags
DMAX_X * DMAX_Y * 2, // SampleSize
0, // Reserved
STATICGUIDOF (KSDATAFORMAT_TYPE_VIDEO), // aka. MEDIATYPE_Video
0x34363248, 0x0000, 0x0010, 0x80, 0x00,
0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71, //aka. MEDIASUBTYPE_YUY2,
STATICGUIDOF (KSDATAFORMAT_SPECIFIER_VIDEOINFO) // FORMAT_VideoInfo
},
FALSE, // BOOL, bFixedSizeSamples (all samples same size?)
FALSE, // BOOL, bTemporalCompression (all I frames?)
0, // Reserved (was StreamDescriptionFlags)
0, // Reserved (was MemoryAllocationFlags
// (KS_VIDEO_ALLOC_*))
//
// _KS_VIDEO_STREAM_CONFIG_CAPS
//
{
STATICGUIDOF( KSDATAFORMAT_SPECIFIER_VIDEOINFO ), // GUID
KS_AnalogVideo_None, // AnalogVideoStandard
DMAX_X, DMAX_Y, // InputSize, (the inherent size of the incoming signal
D_X,D_Y, // MinCroppingSize, smallest rcSrc cropping rect allowed
DMAX_X, DMAX_Y, // MaxCroppingSize, largest rcSrc cropping rect allowed
8, // CropGranularityX, granularity of cropping size
1, // CropGranularityY
8, // CropAlignX, alignment of cropping rect
1, // CropAlignY;
D_X, D_Y, // MinOutputSize, smallest bitmap stream can produce
DMAX_X, DMAX_Y, // MaxOutputSize, largest bitmap stream can produce
8, // OutputGranularityX, granularity of output bitmap size
1, // OutputGranularityY;
0, // StretchTapsX (0 no stretch, 1 pix dup, 2 interp…)
0, // StretchTapsY
0, // ShrinkTapsX
0, // ShrinkTapsY
1428571, // MinFrameInterval, 100 nS units >>7 frames per second
640000000, // MaxFrameInterval, 100 nS units
8 * 2 * 30 * D_X * D_Y, // MinBitsPerSecond;
8 * 2 * 30 * DMAX_X * DMAX_Y, // MaxBitsPerSecond;
},
//
// KS_VIDEOINFOHEADER (default format)
//
{
0, 0, D_X, D_Y, // RECT rcSource;
0, 0, 0, 0, // RECT rcTarget;
DMAX_X * DMAX_Y * 2 * 30, // DWORD dwBitRate;
0L, // DWORD dwBitErrorRate;
1428571, // REFERENCE_TIME AvgTimePerFrame;
sizeof (KS_BITMAPINFOHEADER), // DWORD biSize;
DMAX_X, // LONG biWidth;
DMAX_Y, // LONG biHeight;
1, // WORD biPlanes;
16, // WORD biBitCount;
FOURCC_H264, // DWORD biCompression;
DMAX_X * DMAX_Y * 2, // DWORD biSizeImage;
0, // LONG biXPelsPerMeter;
0, // LONG biYPelsPerMeter;
0, // DWORD biClrUsed;
0 // DWORD biClrImportant;
}
Can anybody tell me hwo to set the correct key frame information to AVI file?
Thank you!
Best Regards,
Gordon</pks_frame_info>