<DIV>Hi, guys</DIV>
<DIV> Anyone takes APIs from avformat lib to write H.264 frames into MP4 file? I am doing this and copied the following code snipset from somewhere.</DIV>
<DIV> </DIV>
<DIV>"</DIV>
<DIV>m_pVideoStream->pts.val = m_nProcessedFramesNum;<BR> <BR>pkt.pts = av_rescale_q(m_pVideoStream->pts.val, c->time_base, m_pVideoStream->time_base);<BR>pkt.data = pData;<BR>pkt.size = uDataLen;</DIV>
<DIV> </DIV>
<DIV>// Write the compressed frame in the media file<BR>av_interleaved_write_frame(m_pFormatCtx, &pkt)</DIV>
<DIV>"</DIV>
<DIV>But indeed, I do not understand why I have to convert the video frame's sequence number, m_nProcessedFramesNum, to AVPacket's PTS with the formula,</DIV>
<DIV> </DIV>
<DIV>av_rescale_q(m_pVideoStream->pts.val, c->time_base, m_pVideoStream->time_base);</DIV>
<DIV> </DIV>
<DIV>in above, c is AVCodecContext of the video stream (m_pVideoStream). And the most wired thing to me is that c->time_base and m_pVideoStream->time_base have</DIV>
<DIV>different values, say, c->time_base is {1,30 }, but m_pVideoStream->time_base takes {1, 15360 }. So much the gap is!</DIV>
<DIV> </DIV>
<DIV>If I directly set pts to m_nProcessedFramesNum, the outcome MP4 file would be decoded and presented extremely faster than expected. What hell is the reason?</DIV>
<DIV>Could anyone please help me to explain this?</DIV>
<DIV> </DIV>
<DIV><BR> </DIV>
<DIV> </DIV>