Firest, name my filter CH264EncoderFilter
1 Read doctument for directshow :directshow.chm, especially Writing directshow filters.
2 Chose Base filter.For my filter will receive yuv422 video stream , convert it to yuv420 then give to libx264.lib for encoding,at end, output h264 stream to down stream. CH264EncoderFilter will have one input pin and one output pin ,manipulate data internal,So I choose CTransformFilter as base Class.
3 Declare the Filter Class
class CH264EncoderFilter : public CTransformFilter
{
/* Declarations will go here. */
public:
CH264EncoderFilter();
~CH264EncoderFilter();
..........................................
};
Declare CLSID:
DEFINE_GUID(CLSID_H264EncoderFilter,
0x69313aff, 0x34c1, 0x4774, 0x94, 0x31, 0xd4, 0x81, 0xb7, 0x2c, 0x4, 0xd3);
};
GUID is generated by Guidgen.exe.
4 Support Media Type Negotiation
CH264EncoderFilter only accetp yuv2 and generate h264 video stream.
CareFull!
In GetMediaType,
..........
VIDEOINFOHEADER *pVih =
reinterpret_cast
(pMediaType->pbFormat);
pVih->bmiHeader.biCompression = FOURCC( '462H' );
..........................
I'm puzzled!
If pVih->bmiHeader.biCompression = FOURCC( 'H264' ) , the avi file recorded by avi muxer and file writer can't be play!
5 Set Allocator Properties
pProp->cbBuffer = DIBSIZE(*pbmi) * 10
6 in Transform encoder yuv420 data.
7 register filter to System
阅读(1269) | 评论(0) | 转发(0) |