diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-05-19 15:28:19 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-05-19 15:35:20 +0200 |
commit | 87f5ede6b52e7d49c823bc070335821b489903e0 (patch) | |
tree | 1414523b56bef672761cb43a92f6bcf31ad66aa0 | |
parent | 2de2b991cac603cc6ad1ff94c706c64a2232f69b (diff) | |
download | ffmpeg-87f5ede6b52e7d49c823bc070335821b489903e0.tar.gz |
ffmpeg: add last_mux_dts_plus_duration
Fixes 1 frame error in the duration and derived values,
introduced by not using AVStream.pts in the previous commit
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | ffmpeg.c | 10 | ||||
-rw-r--r-- | ffmpeg.h | 1 | ||||
-rw-r--r-- | ffmpeg_opt.c | 1 |
3 files changed, 9 insertions, 3 deletions
@@ -658,8 +658,12 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) pkt->dts = max; } } + ost->last_mux_dts_plus_duration = ost->last_mux_dts = pkt->dts; + if (ost->last_mux_dts_plus_duration != AV_NOPTS_VALUE) + ost->last_mux_dts_plus_duration += pkt->duration; + ost->data_size += pkt->size; ost->packets_written++; @@ -1102,7 +1106,7 @@ static void do_video_stats(OutputStream *ost, int frame_size) fprintf(vstats_file,"f_size= %6d ", frame_size); /* compute pts value */ - ti1 = ost->last_mux_dts * av_q2d(enc->time_base); + ti1 = ost->last_mux_dts_plus_duration * av_q2d(enc->time_base); if (ti1 < 0.01) ti1 = 0.01; @@ -1414,8 +1418,8 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti vid = 1; } /* compute min output value */ - if (ost->last_mux_dts != AV_NOPTS_VALUE) - pts = FFMAX(pts, av_rescale_q(ost->last_mux_dts, + if (ost->last_mux_dts_plus_duration != AV_NOPTS_VALUE) + pts = FFMAX(pts, av_rescale_q(ost->last_mux_dts_plus_duration, ost->st->time_base, AV_TIME_BASE_Q)); } @@ -378,6 +378,7 @@ typedef struct OutputStream { int64_t first_pts; /* dts of the last packet sent to the muxer */ int64_t last_mux_dts; + int64_t last_mux_dts_plus_duration; AVBitStreamFilterContext *bitstream_filters; AVCodec *enc; int64_t max_frames; diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index 8e3873c807..6f45785192 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -1152,6 +1152,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e input_streams[source_index]->st->discard = AVDISCARD_NONE; } ost->last_mux_dts = AV_NOPTS_VALUE; + ost->last_mux_dts_plus_duration = AV_NOPTS_VALUE; return ost; } |