summaryrefslogtreecommitdiff
path: root/avconv.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-02-02 12:21:37 +0100
committerAnton Khirnov <anton@khirnov.net>2012-02-07 20:14:41 +0100
commitb34856a116f7ea4748ee7c89bfe1f1bc135d079d (patch)
tree95278fdff3a203ba708338d0bd288956f9e97830 /avconv.c
parent23576b3fbba3f5438fbd6aa6e5e73a39682b942b (diff)
avconv: better next_dts usage.
next_dts is used for estimating the dts of the next packet if it's missing. Therefore, it makes no sense to set it from the pts of the last decoded frame. Also it should be estimated from the current packet duration/ticks_per_frame always, not only when a frame was successfully decoded.
Diffstat (limited to 'avconv.c')
-rw-r--r--avconv.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/avconv.c b/avconv.c
index a4f67ff6fd..92af92430c 100644
--- a/avconv.c
+++ b/avconv.c
@@ -1955,17 +1955,8 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int
/* no picture yet */
return ret;
}
- ist->next_dts = decoded_frame->pts = guess_correct_pts(&ist->pts_ctx, decoded_frame->pkt_pts,
- decoded_frame->pkt_dts);
- if (pkt->duration)
- ist->next_dts += 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_dts += ((int64_t)AV_TIME_BASE *
- ist->st->codec->time_base.num * ticks) /
- ist->st->codec->time_base.den;
- }
+ decoded_frame->pts = guess_correct_pts(&ist->pts_ctx, decoded_frame->pkt_pts,
+ decoded_frame->pkt_dts);
pkt->size = 0;
pre_process_video_frame(ist, (AVPicture *)decoded_frame, &buffer_to_free);
@@ -2128,6 +2119,13 @@ static int output_packet(InputStream *ist,
break;
case AVMEDIA_TYPE_VIDEO:
ret = transcode_video (ist, &avpkt, &got_output, &pkt_pts);
+ if (avpkt.duration)
+ ist->next_dts += av_rescale_q(avpkt.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_dts += av_rescale_q(ticks, ist->st->codec->time_base, AV_TIME_BASE_Q);
+ }
break;
case AVMEDIA_TYPE_SUBTITLE:
ret = transcode_subtitles(ist, &avpkt, &got_output);