avconv: compute next_pts from input packet duration when possible.
authorAnton Khirnov <anton@khirnov.net>
Mon, 28 Nov 2011 10:15:06 +0000 (11:15 +0100)
committerAnton Khirnov <anton@khirnov.net>
Wed, 30 Nov 2011 06:47:43 +0000 (07:47 +0100)
avconv.c

index 067678d..ab0d4ec 100644 (file)
--- a/avconv.c
+++ b/avconv.c
@@ -1747,7 +1747,9 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int
     }
     ist->next_pts = ist->pts = guess_correct_pts(&ist->pts_ctx, decoded_frame->pkt_pts,
                                                  decoded_frame->pkt_dts);
-    if (ist->st->codec->time_base.num != 0) {
+    if (pkt->duration)
+        ist->next_pts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q);
+    else if (ist->st->codec->time_base.num != 0) {
         int ticks      = ist->st->parser ? ist->st->parser->repeat_pict + 1 :
                                            ist->st->codec->ticks_per_frame;
         ist->next_pts += ((int64_t)AV_TIME_BASE *