ffmpeg - Why is packet.pts != frame->pkt_pts in AVFrame? -


trying understand audio/video sync issues via ffmpeg, noticed following. running code

while (av_read_frame(formatctx, &packet) >= 0) {    if (packet.stream_index == videostream)    {       avcodec_decode_video2(videocodecctx, frame, &got_frame, &packet);    }     printf("packet.pts = %d\n", packet.pts);    printf("frame->pkt_pts", frame->pkt_pts); } 

shows frame->pkt_pts in general differs packet.pts, despite documentation claiming frame->pkt_pts the

pts copied avpacket decoded produce frame

moreover noticed difference between 2 big @ places audio , video out of sync.

so, why packet.pts != frame->pkt_pts ?

video may have delayed frames, means input frame , output frame may refer differently ordered units. e.g. in case of mpeg, display order of ibp coded ipb, , pts of input different output, , reordering introduces delay between input pts , output pts. additionally, when using multi-threaded decoding, additional delay of n_threads - 1 packets added between input , output. in these cases, pkt.pts != frame->pkt_pts. display, should rely on frame->pkt_pts.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -