这是使用新的 x264 api 的权利吗,我想得到一个框架,并用 x264 对其进行编码,然后将其保存到 .264 文件中?但我不知道这是对的吗?
picIn.img.plane[0] = pInBuffer ;
picIn.img.plane[1] = pInBuffer +m_VideoEncParam.nWidth*m_VideoEncParam.nHeight ;
picIn.img.plane[2] = pInBuffer +m_VideoEncParam.nWidth*m_VideoEncParam.nHeight*5/4 ;
picIn.img.i_stride[0] = m_VideoEncParam.nWidth ;
picIn.img.i_stride[1] = m_VideoEncParam.nWidth /2 ;
picIn.img.i_stride[2] = m_VideoEncParam.nWidth /2 ;
nRet = x264_encoder_encode(
m_pX264Handle,
&pNal,
&nNalCount,
&picIn,
&picOut);
if (nRet<0)
{
return -1 ;
}
for (int i = 0 ;i<nNalCount ; i++)
{
//memcpy(pOut+nLenOut,&pNal[i],pNal[i].i_payload) ;
x264_nal_encode(m_pX264Handle,pOutBuffer+nLenOut,&pNal[i]);
nLenOut += pNal[i].i_payload ;
}
int nSize = 0 ;
FILE *pFile = fopen(pchFileName,"w") ;
if (!pFile)
{
return -1 ;
}
nSize = fwrite(pOutBuffer,1,nLenOut,pFile) ;
fclose(pFile) ;