From ab9cdd8519e4195640975c84a67ba72a59ecafd1 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 12 Jul 2022 13:14:08 +0200 Subject: ffmpeg handle durations WIP --- fftools/ffmpeg.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index ef7177fc33..7aca91d732 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -802,6 +802,9 @@ static double adjust_frame_pts_to_encoder_tb(OutputFile *of, OutputStream *ost, frame->pts = av_rescale_q(frame->pts, filter_tb, enc->time_base) - av_rescale_q(start_time, AV_TIME_BASE_Q, enc->time_base); + + frame->duration = av_rescale_q(frame->duration, filter_tb, enc->time_base); + frame->time_base = enc->time_base; } early_exit: @@ -812,10 +815,13 @@ early_exit: frame ? av_ts2timestr(orig_pts, &filter_tb) : "NULL", filter_tb.num, filter_tb.den); - av_log(NULL, AV_LOG_INFO, "filter -> pts:%s pts_time:%s exact:%f time_base:%d/%d\n", + av_log(NULL, AV_LOG_INFO, "filter -> pts:%s pts_time:%s exact:%f " + "duration:%"PRId64 " duration_time:%s time_base:%d/%d\n", frame ? av_ts2str(frame->pts) : "NULL", (enc && frame) ? av_ts2timestr(frame->pts, &enc->time_base) : "NULL", float_pts, + frame ? frame->duration : -1, + frame ? av_ts2timestr(frame->duration, &enc->time_base) : "NULL", enc ? enc->time_base.num : -1, enc ? enc->time_base.den : -1); } @@ -921,9 +927,11 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame) if (debug_ts) { av_log(NULL, AV_LOG_INFO, "encoder <- type:%s " - "frame_pts:%s frame_pts_time:%s time_base:%d/%d\n", + "frame_pts:%s frame_pts_time:%s " + "duration:%"PRId64" duration_time:%s time_base:%d/%d\n", type_desc, av_ts2str(frame->pts), av_ts2timestr(frame->pts, &enc->time_base), + frame->duration, av_ts2timestr(frame->duration, &enc->time_base), enc->time_base.num, enc->time_base.den); } } @@ -2280,11 +2288,13 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_ if (debug_ts) { av_log(NULL, AV_LOG_INFO, "decoder -> ist_index:%d type:video " - "frame_pts:%s frame_pts_time:%s best_effort_ts:%"PRId64" best_effort_ts_time:%s keyframe:%d frame_type:%d time_base:%d/%d\n", + "frame_pts:%s frame_pts_time:%s best_effort_ts:%"PRId64" best_effort_ts_time:%s " + "duration:%"PRId64" duration_time:%s keyframe:%d frame_type:%d time_base:%d/%d\n", ist->st->index, av_ts2str(decoded_frame->pts), av_ts2timestr(decoded_frame->pts, &ist->st->time_base), best_effort_timestamp, av_ts2timestr(best_effort_timestamp, &ist->st->time_base), + decoded_frame->duration, av_ts2timestr(decoded_frame->duration, &ist->st->time_base), decoded_frame->key_frame, decoded_frame->pict_type, ist->st->time_base.num, ist->st->time_base.den); } -- cgit v1.2.3