1,初始化解码器
int Init_MP_Decoder(AVCodecID MPCodecID)
{
if(MPCodecID == AV_CODEC_ID_H264 || MPCodecID == AV_CODEC_ID_MPEG2VIDEO)
{
pVideoCodec = avcodec_find_decoder(MPCodecID);
if (!pVideoCodec)
{
return 1;
}
pCodecContext = avcodec_alloc_context3(pVideoCodec);
pVideoFrame = av_frame_alloc();
if(avcodec_open2(pCodecContext, pVideoCodec,NULL) < 0)
{
return 1;
}
pAVCodecParserContext = av_parser_init(MPCodecID);
}
return 0;
}
2,解析TS
int EsDataFromPacket(unsigned char *pInBuf, int nInBufLen, enum MediaType nMediaType)
{
int nRetLen = 0;
unsigned char *pPkt = pInBuf;
unsigned char nPktLen = nInBufLen;
unsigne