[Libav-user] Remuxing sync problem: video is late of some frames.
Nicolas George
george at nsup.org
Thu Jun 11 16:02:51 CEST 2015
Le tridi 23 prairial, an CCXXIII, Talgorn François-Xavier a écrit :
> ret=avcodec_decode_video2(in_stream->codec, yuv_pix->av_frame, &got_something, &orig_pkt);
> if(!got_something)
> {
> INFO(stderr, ":-( Unable to encode yuv frame.\n");
> exit(0);
> }
This is wrong. Some codecs may consume hundreds of frames before outputting
a single packet.
> styl_pkt.pts = av_rescale_q_rnd(orig_pkt.pts, in_stream->time_base, out_stream->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
> styl_pkt.dts = av_rescale_q_rnd(orig_pkt.dts, in_stream->time_base, out_stream->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
> styl_pkt.duration = av_rescale_q(orig_pkt.duration, in_stream->time_base, out_stream->time_base);
This is wrong too: the frame you just encoded does not necessarily come from
orig_pkt. You need to use the timestamp fields in the frame.
In the future, please provide minimal but complete programs. Your program is
not minimal, it contains a lot of code unnecessary to show the problem, and
nor is it complete.
Regards,
--
Nicolas George
More information about the Libav-user
mailing list