Commit 1f359c85 authored by Michael Niedermayer's avatar Michael Niedermayer

ffmpeg: use av_stream_get_end_pts()

Simplifies code and should correct timing values when -*sync drop is used
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 7f7080dc
...@@ -658,12 +658,8 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) ...@@ -658,12 +658,8 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
pkt->dts = max; pkt->dts = max;
} }
} }
ost->last_mux_dts_plus_duration =
ost->last_mux_dts = pkt->dts; 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->data_size += pkt->size;
ost->packets_written++; ost->packets_written++;
...@@ -1107,7 +1103,7 @@ static void do_video_stats(OutputStream *ost, int frame_size) ...@@ -1107,7 +1103,7 @@ static void do_video_stats(OutputStream *ost, int frame_size)
fprintf(vstats_file,"f_size= %6d ", frame_size); fprintf(vstats_file,"f_size= %6d ", frame_size);
/* compute pts value */ /* compute pts value */
ti1 = ost->last_mux_dts_plus_duration * av_q2d(ost->st->time_base); ti1 = av_stream_get_end_pts(ost->st) * av_q2d(ost->st->time_base);
if (ti1 < 0.01) if (ti1 < 0.01)
ti1 = 0.01; ti1 = 0.01;
...@@ -1419,8 +1415,8 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti ...@@ -1419,8 +1415,8 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
vid = 1; vid = 1;
} }
/* compute min output value */ /* compute min output value */
if (ost->last_mux_dts_plus_duration != AV_NOPTS_VALUE) if (av_stream_get_end_pts(ost->st) != AV_NOPTS_VALUE)
pts = FFMAX(pts, av_rescale_q(ost->last_mux_dts_plus_duration, pts = FFMAX(pts, av_rescale_q(av_stream_get_end_pts(ost->st),
ost->st->time_base, AV_TIME_BASE_Q)); ost->st->time_base, AV_TIME_BASE_Q));
} }
......
...@@ -378,7 +378,6 @@ typedef struct OutputStream { ...@@ -378,7 +378,6 @@ typedef struct OutputStream {
int64_t first_pts; int64_t first_pts;
/* dts of the last packet sent to the muxer */ /* dts of the last packet sent to the muxer */
int64_t last_mux_dts; int64_t last_mux_dts;
int64_t last_mux_dts_plus_duration;
AVBitStreamFilterContext *bitstream_filters; AVBitStreamFilterContext *bitstream_filters;
AVCodec *enc; AVCodec *enc;
int64_t max_frames; int64_t max_frames;
......
...@@ -1152,7 +1152,6 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e ...@@ -1152,7 +1152,6 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
input_streams[source_index]->st->discard = AVDISCARD_NONE; input_streams[source_index]->st->discard = AVDISCARD_NONE;
} }
ost->last_mux_dts = AV_NOPTS_VALUE; ost->last_mux_dts = AV_NOPTS_VALUE;
ost->last_mux_dts_plus_duration = AV_NOPTS_VALUE;
return ost; return ost;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment