<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">I don't know if this is right but this is how I rescale timestamps:<div><div> //Back to yuv for encoding flattened image</div><div>                yuv_pix->av_frame=RGBtoYUV(rgb_pix->av_frame, in_stream->codec);</div><div><br></div><div>                avcodec_encode_video2(out_stream->codec, &styl_pkt, yuv_pix->av_frame, &got_something);</div><div>                if(!got_something)</div><div>                {</div><div>                    INFO(stderr, ":-( Unable to encode yuv frame.\n");</div><div>                    exit(0);</div><div>                }      </div><div>                //convert timestamps from in time_base to out time_base</div><div>                av_packet_rescale_ts(&styl_pkt, in_stream->time_base, out_stream->time_base);</div><div><br></div><div>                //log_packet(in_video_ctx->format_ctx, &orig_pkt, "Video orig. pkt");</div><div>                //log_packet(out_video_ctx->format_ctx, &styl_pkt, "Video styl. pkt");</div><div>                ret = av_write_frame(out_video_ctx->format_ctx, &styl_pkt);</div><div>                if (ret < 0)</div><div>                {</div><div>                    INFO(stderr, "Error muxing packet\n");</div><div>                    break;</div><div>                }</div><div><br></div><div>I'm sure I'm wrong somewhere with this timestamps management but I can't figure out how.</div><div>Thanks again if you can help me further!</div><div><br></div><div><br></div><div><br></div><div><div>Le 3 sept. 2015 à 18:23, Robert Krüger <<a href="mailto:krueger@lesspain.de">krueger@lesspain.de</a>> a écrit :</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 3, 2015 at 5:41 PM, Talgorn François-Xavier <span dir="ltr"><<a href="mailto:fxtalgorn-at-yahoo.fr@ffmpeg.org" target="_blank">fxtalgorn-at-yahoo.fr@ffmpeg.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi Krueger,<div><br></div><div>Thanks for your reply.</div><div>I did check the timestamps and durations of packets.</div><div>It appears that respectives timestamps (original/encoded) are in different formats but consistent (incremental).</div><div>I set the timebase for encoded file to the same as the original (in_ctx->format_ctx is the original context).</div><div><br></div><div><div>    o_codec_ctx->time_base.num = in_ctx->format_ctx->streams[in_ctx->video_stream_idx]->codec->time_base;</div><div>    o_codec_ctx->time_base.den = in_ctx->format_ctx->streams[in_ctx->video_stream_idx]->codec->time_base;</div><div><br></div><div>I don't know if this is OK to duplicate a timebase from H264 to be used in a MP4 context.</div><div>Since it defines the frame rate only (not the ticks/frame) it should OK I guess.</div><div><br></div></div></div></blockquote><div>no, it does not. mov/mp4 don't have a concept like frame rate.</div><div><br></div><div>The encoder gives you packets that have timestamps that are based on what you gave the encoder as timebase. The muxer has the freedom to change that timebase in avformat_write_header and if it does, the packets you get from the encoder have incorrect timestamps, if you don't rescale them to the timebase of the AVStream modified by the muxer. Check the example muxing.c in the docs. You have to do what's done there (see line 83). If you don't, what you describe (incorrect frame rate) may very well be the result. </div></div>
</div></div>
_______________________________________________<br>Libav-user mailing list<br><a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>http://ffmpeg.org/mailman/listinfo/libav-user<br></blockquote></div><br></div></body></html>