接着上面写,第二天用第二种方法把视频显示出来了,在接收网络数据流后,再加上如下三个字节,就可以正确解码
unsigned char start_code[3] = {0x00, 0x00, 0x01};
memcpy(m_pMediaDataBuffer+m_nUsefulBytes, start_code, 3);
解码后显示方法如下,需要做一个转换(这里化了很上的时间,最开始没有进行如下的转换,一直画不出来)
if (nGotPicture)
{
int size=avpicture_get_size(PIX_FMT_YUV420P, m_pCodecContext->width, m_pCodecContext->height);
if(m_pFillbuf == NULL)
{
m_pFillbuf = av_malloc(size);
}
avpicture_fill(m_pDrawPicture, m_pFillbuf, PIX_FMT_YUV420P, m_pCodecContext->width, m_pCodecContext->height);
img_convert(m_pDrawPicture, PIX_FMT_YUV420P, m_pOutPicture, m_pCodecContext->pix_fmt, m_pCodecContext->width, m_pCodecContext->height);
DrawYUV420P(m_hVideoWnd, m_pDrawPicture);
}
对于上篇写着的两种方法,第二种方法适用一些,第一种方法在接H264时获取AVInputFormat总是错误.
后面几天的工作:
用directshoe filter显示H264实时流。再进行音频的传输功能
最后是音视同步