I'm using the SDK for h.264 encoding and muxing. when i read the example of "msdk_ffmpeg_integration", i found that the sdk handles PTS as follow:
mfxStatus FFMPEGWriter::WriteNextFrame(mfxBitstream *pMfxBitstream, bool isPrint)
{
++m_nProcessedFramesNum;
AVPacket pkt;
av_init_packet(&pkt);
AVCodecContext *c = m_pVideoStream->codec;
m_pVideoStream->pts.val = m_nProcessedFramesNum;
pkt.pts = av_rescale_q(m_pVideoStream->pts.val, c->time_base, m_pVideoStream->time_base);
....
}
It just simply use the ProcessedFramesNum to calc PTS,but i think it's not the best(or correct) method.
As I know, h.264 has I、P、B frame, and the PTS will not be continuous,so how can I get the correct PTS and DTS?