* [FFmpeg-devel] [PATCH 1/8] doc/ffmpeg.texi: drop a non-existent option @ 2023-01-04 16:42 Anton Khirnov 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 2/8] fftools/ffmpeg: stop using AVCodecContext.sample_rate in decode_audio() Anton Khirnov ` (6 more replies) 0 siblings, 7 replies; 12+ messages in thread From: Anton Khirnov @ 2023-01-04 16:42 UTC (permalink / raw) To: ffmpeg-devel -ilme has not existed for 17 years, since 637b5326f3441b53e2f1004085c4d570ba2d7758 --- doc/ffmpeg.texi | 6 ------ 1 file changed, 6 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 0367930a3b..65634b82cf 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1011,12 +1011,6 @@ list separated with slashes. Two first values are the beginning and end frame numbers, last one is quantizer to use if positive, or quality factor if negative. -@item -ilme -Force interlacing support in encoder (MPEG-2 and MPEG-4 only). -Use this option if your input file is interlaced and you want -to keep the interlaced format for minimum losses. -The alternative is to deinterlace the input stream by use of a filter -such as @code{yadif} or @code{bwdif}, but deinterlacing introduces losses. @item -psnr Calculate PSNR of compressed frames. This option is deprecated, pass the PSNR flag to the encoder instead, using @code{-flags +psnr}. -- 2.35.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 12+ messages in thread
* [FFmpeg-devel] [PATCH 2/8] fftools/ffmpeg: stop using AVCodecContext.sample_rate in decode_audio() 2023-01-04 16:42 [FFmpeg-devel] [PATCH 1/8] doc/ffmpeg.texi: drop a non-existent option Anton Khirnov @ 2023-01-04 16:42 ` Anton Khirnov 2023-01-05 0:46 ` Michael Niedermayer 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 3/8] fftools/ffmpeg: fix stream id in an error message Anton Khirnov ` (5 subsequent siblings) 6 siblings, 1 reply; 12+ messages in thread From: Anton Khirnov @ 2023-01-04 16:42 UTC (permalink / raw) To: ffmpeg-devel Use the decoded frame's sample_rate instead, which is the authoritative value. Drop a now-obsolete check validating AVCodecContext.sample_rate. --- fftools/ffmpeg.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 881d6f0af2..2dbfeca020 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2017,11 +2017,6 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output, if (ret < 0) *decode_failed = 1; - if (ret >= 0 && avctx->sample_rate <= 0) { - av_log(avctx, AV_LOG_ERROR, "Sample rate %d invalid\n", avctx->sample_rate); - ret = AVERROR_INVALIDDATA; - } - if (ret != AVERROR_EOF) check_decode_result(ist, got_output, ret); @@ -2034,9 +2029,9 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output, /* increment next_dts to use for the case where the input stream does not have timestamps or there are multiple frames in the packet */ ist->next_pts += ((int64_t)AV_TIME_BASE * decoded_frame->nb_samples) / - avctx->sample_rate; + decoded_frame->sample_rate; ist->next_dts += ((int64_t)AV_TIME_BASE * decoded_frame->nb_samples) / - avctx->sample_rate; + decoded_frame->sample_rate; if (decoded_frame->pts != AV_NOPTS_VALUE) { decoded_frame_tb = ist->st->time_base; @@ -2054,8 +2049,10 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output, ist->prev_pkt_pts = pkt->pts; if (decoded_frame->pts != AV_NOPTS_VALUE) decoded_frame->pts = av_rescale_delta(decoded_frame_tb, decoded_frame->pts, - (AVRational){1, avctx->sample_rate}, decoded_frame->nb_samples, &ist->filter_in_rescale_delta_last, - (AVRational){1, avctx->sample_rate}); + (AVRational){1, decoded_frame->sample_rate}, + decoded_frame->nb_samples, + &ist->filter_in_rescale_delta_last, + (AVRational){1, decoded_frame->sample_rate}); ist->nb_samples = decoded_frame->nb_samples; err = send_frame_to_filters(ist, decoded_frame); -- 2.35.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/8] fftools/ffmpeg: stop using AVCodecContext.sample_rate in decode_audio() 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 2/8] fftools/ffmpeg: stop using AVCodecContext.sample_rate in decode_audio() Anton Khirnov @ 2023-01-05 0:46 ` Michael Niedermayer 2023-01-05 11:09 ` Anton Khirnov 0 siblings, 1 reply; 12+ messages in thread From: Michael Niedermayer @ 2023-01-05 0:46 UTC (permalink / raw) To: FFmpeg development discussions and patches [-- Attachment #1.1: Type: text/plain, Size: 729 bytes --] On Wed, Jan 04, 2023 at 05:42:40PM +0100, Anton Khirnov wrote: > Use the decoded frame's sample_rate instead, which is the authoritative > value. > > Drop a now-obsolete check validating AVCodecContext.sample_rate. > --- > fftools/ffmpeg.c | 15 ++++++--------- > 1 file changed, 6 insertions(+), 9 deletions(-) Causes division by 0 will send you the sample privately thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 1 "Used only once" - "Some unspecified defect prevented a second use" "In good condition" - "Can be repaird by experienced expert" "As is" - "You wouldnt want it even if you were payed for it, if you knew ..." [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 195 bytes --] [-- Attachment #2: Type: text/plain, Size: 251 bytes --] _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/8] fftools/ffmpeg: stop using AVCodecContext.sample_rate in decode_audio() 2023-01-05 0:46 ` Michael Niedermayer @ 2023-01-05 11:09 ` Anton Khirnov 0 siblings, 0 replies; 12+ messages in thread From: Anton Khirnov @ 2023-01-05 11:09 UTC (permalink / raw) To: FFmpeg development discussions and patches Quoting Michael Niedermayer (2023-01-05 01:46:45) > On Wed, Jan 04, 2023 at 05:42:40PM +0100, Anton Khirnov wrote: > > Use the decoded frame's sample_rate instead, which is the authoritative > > value. > > > > Drop a now-obsolete check validating AVCodecContext.sample_rate. > > --- > > fftools/ffmpeg.c | 15 ++++++--------- > > 1 file changed, 6 insertions(+), 9 deletions(-) > > Causes division by 0 > will send you the sample privately Should be fixed in the patchset I just sent. IMO lavc returning invalid frames is a bug that should be fixed in lavc, so this patch should still go in. -- Anton Khirnov _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 12+ messages in thread
* [FFmpeg-devel] [PATCH 3/8] fftools/ffmpeg: fix stream id in an error message. 2023-01-04 16:42 [FFmpeg-devel] [PATCH 1/8] doc/ffmpeg.texi: drop a non-existent option Anton Khirnov 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 2/8] fftools/ffmpeg: stop using AVCodecContext.sample_rate in decode_audio() Anton Khirnov @ 2023-01-04 16:42 ` Anton Khirnov 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 4/8] fftools/ffmpeg: rename a variable to be more descriptive Anton Khirnov ` (4 subsequent siblings) 6 siblings, 0 replies; 12+ messages in thread From: Anton Khirnov @ 2023-01-04 16:42 UTC (permalink / raw) To: ffmpeg-devel Broken in 7ef7a22251b8 --- fftools/ffmpeg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 2dbfeca020..00e4be68ea 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3797,7 +3797,8 @@ static int transcode(void) packets_written = atomic_load(&ost->packets_written); total_packets_written += packets_written; if (!packets_written && (abort_on_flags & ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM)) { - av_log(NULL, AV_LOG_FATAL, "Empty output on stream %d.\n", i); + av_log(NULL, AV_LOG_FATAL, "Empty output on stream %d:%d.\n", + ost->file_index, ost->index); exit_program(1); } } -- 2.35.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 12+ messages in thread
* [FFmpeg-devel] [PATCH 4/8] fftools/ffmpeg: rename a variable to be more descriptive 2023-01-04 16:42 [FFmpeg-devel] [PATCH 1/8] doc/ffmpeg.texi: drop a non-existent option Anton Khirnov 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 2/8] fftools/ffmpeg: stop using AVCodecContext.sample_rate in decode_audio() Anton Khirnov 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 3/8] fftools/ffmpeg: fix stream id in an error message Anton Khirnov @ 2023-01-04 16:42 ` Anton Khirnov 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 5/8] fftools/ffmpeg: move video frame dup/drop logic into its own function Anton Khirnov ` (3 subsequent siblings) 6 siblings, 0 replies; 12+ messages in thread From: Anton Khirnov @ 2023-01-04 16:42 UTC (permalink / raw) To: ffmpeg-devel --- fftools/ffmpeg.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 00e4be68ea..66a24a1a9c 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1088,7 +1088,7 @@ static void do_video_out(OutputFile *of, int ret; AVCodecContext *enc = ost->enc_ctx; AVRational frame_rate; - int64_t nb_frames, nb0_frames, i; + int64_t nb_frames, nb_frames_prev, i; double delta, delta0; double duration = 0; InputStream *ist = ost->ist; @@ -1114,9 +1114,9 @@ static void do_video_out(OutputFile *of, if (!next_picture) { //end, flushing - nb0_frames = nb_frames = mid_pred(ost->last_nb0_frames[0], - ost->last_nb0_frames[1], - ost->last_nb0_frames[2]); + nb_frames_prev = nb_frames = mid_pred(ost->last_nb0_frames[0], + ost->last_nb0_frames[1], + ost->last_nb0_frames[2]); } else { double sync_ipts = adjust_frame_pts_to_encoder_tb(of, ost, next_picture); /* delta0 is the "drift" between the input frame (next_picture) and @@ -1124,8 +1124,10 @@ static void do_video_out(OutputFile *of, delta0 = sync_ipts - ost->next_pts; delta = delta0 + duration; + // tracks the number of times the PREVIOUS frame should be duplicated, + // mostly for variable framerate (VFR) + nb_frames_prev = 0; /* by default, we output a single frame */ - nb0_frames = 0; // tracks the number of times the PREVIOUS frame should be duplicated, mostly for variable framerate (VFR) nb_frames = 1; if (delta0 < 0 && @@ -1158,7 +1160,7 @@ static void do_video_out(OutputFile *of, else if (delta > 1.1) { nb_frames = llrintf(delta); if (delta0 > 1.1) - nb0_frames = llrintf(delta0 - 0.6); + nb_frames_prev = llrintf(delta0 - 0.6); } next_picture->duration = 1; break; @@ -1182,35 +1184,35 @@ static void do_video_out(OutputFile *of, memmove(ost->last_nb0_frames + 1, ost->last_nb0_frames, sizeof(ost->last_nb0_frames[0]) * (FF_ARRAY_ELEMS(ost->last_nb0_frames) - 1)); - ost->last_nb0_frames[0] = nb0_frames; + ost->last_nb0_frames[0] = nb_frames_prev; - if (nb0_frames == 0 && ost->last_dropped) { + if (nb_frames_prev == 0 && ost->last_dropped) { nb_frames_drop++; av_log(NULL, AV_LOG_VERBOSE, "*** dropping frame %"PRId64" from stream %d at ts %"PRId64"\n", ost->vsync_frame_number, ost->st->index, ost->last_frame->pts); } - if (nb_frames > (nb0_frames && ost->last_dropped) + (nb_frames > nb0_frames)) { + if (nb_frames > (nb_frames_prev && ost->last_dropped) + (nb_frames > nb_frames_prev)) { if (nb_frames > dts_error_threshold * 30) { av_log(NULL, AV_LOG_ERROR, "%"PRId64" frame duplication too large, skipping\n", nb_frames - 1); nb_frames_drop++; return; } - nb_frames_dup += nb_frames - (nb0_frames && ost->last_dropped) - (nb_frames > nb0_frames); + nb_frames_dup += nb_frames - (nb_frames_prev && ost->last_dropped) - (nb_frames > nb_frames_prev); av_log(NULL, AV_LOG_VERBOSE, "*** %"PRId64" dup!\n", nb_frames - 1); if (nb_frames_dup > dup_warning) { av_log(NULL, AV_LOG_WARNING, "More than %"PRIu64" frames duplicated\n", dup_warning); dup_warning *= 10; } } - ost->last_dropped = nb_frames == nb0_frames && next_picture; + ost->last_dropped = nb_frames == nb_frames_prev && next_picture; ost->kf.dropped_keyframe = ost->last_dropped && next_picture && next_picture->key_frame; /* duplicates frame if needed */ for (i = 0; i < nb_frames; i++) { AVFrame *in_picture; - if (i < nb0_frames && ost->last_frame->buf[0]) { + if (i < nb_frames_prev && ost->last_frame->buf[0]) { in_picture = ost->last_frame; } else in_picture = next_picture; -- 2.35.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 12+ messages in thread
* [FFmpeg-devel] [PATCH 5/8] fftools/ffmpeg: move video frame dup/drop logic into its own function 2023-01-04 16:42 [FFmpeg-devel] [PATCH 1/8] doc/ffmpeg.texi: drop a non-existent option Anton Khirnov ` (2 preceding siblings ...) 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 4/8] fftools/ffmpeg: rename a variable to be more descriptive Anton Khirnov @ 2023-01-04 16:42 ` Anton Khirnov 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 6/8] fftools/ffmpeg: reindent after previous commit Anton Khirnov ` (2 subsequent siblings) 6 siblings, 0 replies; 12+ messages in thread From: Anton Khirnov @ 2023-01-04 16:42 UTC (permalink / raw) To: ffmpeg-devel --- fftools/ffmpeg.c | 137 ++++++++++++++++++++++++++--------------------- 1 file changed, 75 insertions(+), 62 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 66a24a1a9c..04de57e41e 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1030,6 +1030,79 @@ static void do_subtitle_out(OutputFile *of, } } +/* Convert frame timestamps to the encoder timebase and decide how many times + * should this (and possibly previous) frame be repeated in order to conform to + * desired target framerate (if any). + */ +static void video_sync_process(OutputFile *of, OutputStream *ost, + AVFrame *next_picture, double duration, + int64_t *nb_frames, int64_t *nb_frames_prev) +{ + double delta0, delta; + + double sync_ipts = adjust_frame_pts_to_encoder_tb(of, ost, next_picture); + /* delta0 is the "drift" between the input frame (next_picture) and + * where it would fall in the output. */ + delta0 = sync_ipts - ost->next_pts; + delta = delta0 + duration; + + // tracks the number of times the PREVIOUS frame should be duplicated, + // mostly for variable framerate (VFR) + *nb_frames_prev = 0; + /* by default, we output a single frame */ + *nb_frames = 1; + + if (delta0 < 0 && + delta > 0 && + ost->vsync_method != VSYNC_PASSTHROUGH && + ost->vsync_method != VSYNC_DROP) { + if (delta0 < -0.6) { + av_log(NULL, AV_LOG_VERBOSE, "Past duration %f too large\n", -delta0); + } else + av_log(NULL, AV_LOG_DEBUG, "Clipping frame in rate conversion by %f\n", -delta0); + sync_ipts = ost->next_pts; + duration += delta0; + delta0 = 0; + } + + switch (ost->vsync_method) { + case VSYNC_VSCFR: + if (ost->vsync_frame_number == 0 && delta0 >= 0.5) { + av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta0)); + delta = duration; + delta0 = 0; + ost->next_pts = llrint(sync_ipts); + } + case VSYNC_CFR: + // FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c + if (frame_drop_threshold && delta < frame_drop_threshold && ost->vsync_frame_number) { + *nb_frames = 0; + } else if (delta < -1.1) + *nb_frames = 0; + else if (delta > 1.1) { + *nb_frames = llrintf(delta); + if (delta0 > 1.1) + *nb_frames_prev = llrintf(delta0 - 0.6); + } + next_picture->duration = 1; + break; + case VSYNC_VFR: + if (delta <= -0.6) + *nb_frames = 0; + else if (delta > 0.6) + ost->next_pts = llrint(sync_ipts); + next_picture->duration = duration; + break; + case VSYNC_DROP: + case VSYNC_PASSTHROUGH: + next_picture->duration = duration; + ost->next_pts = llrint(sync_ipts); + break; + default: + av_assert0(0); + } +} + static enum AVPictureType forced_kf_apply(KeyframeForceCtx *kf, AVRational tb, const AVFrame *in_picture, int dup_idx) { @@ -1089,7 +1162,6 @@ static void do_video_out(OutputFile *of, AVCodecContext *enc = ost->enc_ctx; AVRational frame_rate; int64_t nb_frames, nb_frames_prev, i; - double delta, delta0; double duration = 0; InputStream *ist = ost->ist; AVFilterContext *filter = ost->filter->filter; @@ -1118,67 +1190,8 @@ static void do_video_out(OutputFile *of, ost->last_nb0_frames[1], ost->last_nb0_frames[2]); } else { - double sync_ipts = adjust_frame_pts_to_encoder_tb(of, ost, next_picture); - /* delta0 is the "drift" between the input frame (next_picture) and - * where it would fall in the output. */ - delta0 = sync_ipts - ost->next_pts; - delta = delta0 + duration; - - // tracks the number of times the PREVIOUS frame should be duplicated, - // mostly for variable framerate (VFR) - nb_frames_prev = 0; - /* by default, we output a single frame */ - nb_frames = 1; - - if (delta0 < 0 && - delta > 0 && - ost->vsync_method != VSYNC_PASSTHROUGH && - ost->vsync_method != VSYNC_DROP) { - if (delta0 < -0.6) { - av_log(NULL, AV_LOG_VERBOSE, "Past duration %f too large\n", -delta0); - } else - av_log(NULL, AV_LOG_DEBUG, "Clipping frame in rate conversion by %f\n", -delta0); - sync_ipts = ost->next_pts; - duration += delta0; - delta0 = 0; - } - - switch (ost->vsync_method) { - case VSYNC_VSCFR: - if (ost->vsync_frame_number == 0 && delta0 >= 0.5) { - av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta0)); - delta = duration; - delta0 = 0; - ost->next_pts = llrint(sync_ipts); - } - case VSYNC_CFR: - // FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c - if (frame_drop_threshold && delta < frame_drop_threshold && ost->vsync_frame_number) { - nb_frames = 0; - } else if (delta < -1.1) - nb_frames = 0; - else if (delta > 1.1) { - nb_frames = llrintf(delta); - if (delta0 > 1.1) - nb_frames_prev = llrintf(delta0 - 0.6); - } - next_picture->duration = 1; - break; - case VSYNC_VFR: - if (delta <= -0.6) - nb_frames = 0; - else if (delta > 0.6) - ost->next_pts = llrint(sync_ipts); - next_picture->duration = duration; - break; - case VSYNC_DROP: - case VSYNC_PASSTHROUGH: - next_picture->duration = duration; - ost->next_pts = llrint(sync_ipts); - break; - default: - av_assert0(0); - } + video_sync_process(of, ost, next_picture, duration, + &nb_frames, &nb_frames_prev); } memmove(ost->last_nb0_frames + 1, -- 2.35.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 12+ messages in thread
* [FFmpeg-devel] [PATCH 6/8] fftools/ffmpeg: reindent after previous commit 2023-01-04 16:42 [FFmpeg-devel] [PATCH 1/8] doc/ffmpeg.texi: drop a non-existent option Anton Khirnov ` (3 preceding siblings ...) 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 5/8] fftools/ffmpeg: move video frame dup/drop logic into its own function Anton Khirnov @ 2023-01-04 16:42 ` Anton Khirnov 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 7/8] doc/ffmpeg: improve -r documentation Anton Khirnov 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 8/8] fftools/ffmpeg: always generate CFR output when -r is used Anton Khirnov 6 siblings, 0 replies; 12+ messages in thread From: Anton Khirnov @ 2023-01-04 16:42 UTC (permalink / raw) To: ffmpeg-devel --- fftools/ffmpeg.c | 116 +++++++++++++++++++++++------------------------ 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 04de57e41e..f722ae7632 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1040,67 +1040,67 @@ static void video_sync_process(OutputFile *of, OutputStream *ost, { double delta0, delta; - double sync_ipts = adjust_frame_pts_to_encoder_tb(of, ost, next_picture); - /* delta0 is the "drift" between the input frame (next_picture) and - * where it would fall in the output. */ - delta0 = sync_ipts - ost->next_pts; - delta = delta0 + duration; - - // tracks the number of times the PREVIOUS frame should be duplicated, - // mostly for variable framerate (VFR) - *nb_frames_prev = 0; - /* by default, we output a single frame */ - *nb_frames = 1; - - if (delta0 < 0 && - delta > 0 && - ost->vsync_method != VSYNC_PASSTHROUGH && - ost->vsync_method != VSYNC_DROP) { - if (delta0 < -0.6) { - av_log(NULL, AV_LOG_VERBOSE, "Past duration %f too large\n", -delta0); - } else - av_log(NULL, AV_LOG_DEBUG, "Clipping frame in rate conversion by %f\n", -delta0); - sync_ipts = ost->next_pts; - duration += delta0; - delta0 = 0; - } + double sync_ipts = adjust_frame_pts_to_encoder_tb(of, ost, next_picture); + /* delta0 is the "drift" between the input frame (next_picture) and + * where it would fall in the output. */ + delta0 = sync_ipts - ost->next_pts; + delta = delta0 + duration; + + // tracks the number of times the PREVIOUS frame should be duplicated, + // mostly for variable framerate (VFR) + *nb_frames_prev = 0; + /* by default, we output a single frame */ + *nb_frames = 1; + + if (delta0 < 0 && + delta > 0 && + ost->vsync_method != VSYNC_PASSTHROUGH && + ost->vsync_method != VSYNC_DROP) { + if (delta0 < -0.6) { + av_log(NULL, AV_LOG_VERBOSE, "Past duration %f too large\n", -delta0); + } else + av_log(NULL, AV_LOG_DEBUG, "Clipping frame in rate conversion by %f\n", -delta0); + sync_ipts = ost->next_pts; + duration += delta0; + delta0 = 0; + } - switch (ost->vsync_method) { - case VSYNC_VSCFR: - if (ost->vsync_frame_number == 0 && delta0 >= 0.5) { - av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta0)); - delta = duration; - delta0 = 0; - ost->next_pts = llrint(sync_ipts); - } - case VSYNC_CFR: - // FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c - if (frame_drop_threshold && delta < frame_drop_threshold && ost->vsync_frame_number) { - *nb_frames = 0; - } else if (delta < -1.1) - *nb_frames = 0; - else if (delta > 1.1) { - *nb_frames = llrintf(delta); - if (delta0 > 1.1) - *nb_frames_prev = llrintf(delta0 - 0.6); - } - next_picture->duration = 1; - break; - case VSYNC_VFR: - if (delta <= -0.6) - *nb_frames = 0; - else if (delta > 0.6) - ost->next_pts = llrint(sync_ipts); - next_picture->duration = duration; - break; - case VSYNC_DROP: - case VSYNC_PASSTHROUGH: - next_picture->duration = duration; + switch (ost->vsync_method) { + case VSYNC_VSCFR: + if (ost->vsync_frame_number == 0 && delta0 >= 0.5) { + av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta0)); + delta = duration; + delta0 = 0; ost->next_pts = llrint(sync_ipts); - break; - default: - av_assert0(0); } + case VSYNC_CFR: + // FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c + if (frame_drop_threshold && delta < frame_drop_threshold && ost->vsync_frame_number) { + *nb_frames = 0; + } else if (delta < -1.1) + *nb_frames = 0; + else if (delta > 1.1) { + *nb_frames = llrintf(delta); + if (delta0 > 1.1) + *nb_frames_prev = llrintf(delta0 - 0.6); + } + next_picture->duration = 1; + break; + case VSYNC_VFR: + if (delta <= -0.6) + *nb_frames = 0; + else if (delta > 0.6) + ost->next_pts = llrint(sync_ipts); + next_picture->duration = duration; + break; + case VSYNC_DROP: + case VSYNC_PASSTHROUGH: + next_picture->duration = duration; + ost->next_pts = llrint(sync_ipts); + break; + default: + av_assert0(0); + } } static enum AVPictureType forced_kf_apply(KeyframeForceCtx *kf, AVRational tb, -- 2.35.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 12+ messages in thread
* [FFmpeg-devel] [PATCH 7/8] doc/ffmpeg: improve -r documentation 2023-01-04 16:42 [FFmpeg-devel] [PATCH 1/8] doc/ffmpeg.texi: drop a non-existent option Anton Khirnov ` (4 preceding siblings ...) 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 6/8] fftools/ffmpeg: reindent after previous commit Anton Khirnov @ 2023-01-04 16:42 ` Anton Khirnov 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 8/8] fftools/ffmpeg: always generate CFR output when -r is used Anton Khirnov 6 siblings, 0 replies; 12+ messages in thread From: Anton Khirnov @ 2023-01-04 16:42 UTC (permalink / raw) To: ffmpeg-devel Explain different behavior for encoding and streamcopy. --- doc/ffmpeg.texi | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 65634b82cf..67b3294256 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -877,9 +877,20 @@ This is not the same as the @option{-framerate} option used for some input forma like image2 or v4l2 (it used to be the same in older versions of FFmpeg). If in doubt use @option{-framerate} instead of the input option @option{-r}. -As an output option, duplicate or drop input frames to achieve constant output +As an output option: +@table @option +@item video encoding +Duplicate or drop frames right before encoding them to achieve constant output frame rate @var{fps}. +@item video streamcopy +Indicate to the muxer that @var{fps} is the stream frame rate. No data is +dropped or duplicated in this case. This may produce invalid files if @var{fps} +does not match the actual stream frame rate as determined by packet timestamps. +See also the @code{setts} bitstream filter. + +@end table + @item -fpsmax[:@var{stream_specifier}] @var{fps} (@emph{output,per-stream}) Set maximum frame rate (Hz value, fraction or abbreviation). -- 2.35.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 12+ messages in thread
* [FFmpeg-devel] [PATCH 8/8] fftools/ffmpeg: always generate CFR output when -r is used 2023-01-04 16:42 [FFmpeg-devel] [PATCH 1/8] doc/ffmpeg.texi: drop a non-existent option Anton Khirnov ` (5 preceding siblings ...) 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 7/8] doc/ffmpeg: improve -r documentation Anton Khirnov @ 2023-01-04 16:42 ` Anton Khirnov 2023-01-04 17:37 ` Paul B Mahol 6 siblings, 1 reply; 12+ messages in thread From: Anton Khirnov @ 2023-01-04 16:42 UTC (permalink / raw) To: ffmpeg-devel Current code may, depending on the muxer, decide to use VSYNC_VFR tagged with the specified framerate, without actually performing framerate conversion. This is clearly wrong and against the documentation, which states unambiguously that -r should produce CFR output for video encoding. FATE test changes: * nuv-rtjpeg: replace -r with '-enc_time_base -1', which keeps the original timebase. Output frames are now produced with proper durations. * filter-mpdecimate: just drop the -r option, it is unnecessary * filter-fps-r: remove, this test makes no sense and actually produces broken VFR output (with incorrect frame durations). --- fftools/ffmpeg_mux_init.c | 16 +++++--- tests/fate/filter-video.mak | 5 +-- tests/fate/video.mak | 3 +- tests/ref/fate/filter-fps-r | 78 ------------------------------------- tests/ref/fate/nuv-rtjpeg | 16 ++++---- 5 files changed, 22 insertions(+), 96 deletions(-) delete mode 100644 tests/ref/fate/filter-fps-r diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 0280759b05..9eea8639dc 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -443,10 +443,6 @@ static OutputStream *new_video_stream(Muxer *mux, const OptionsContext *o, Input exit_program(1); } - if ((frame_rate || max_frame_rate) && - video_sync_method == VSYNC_PASSTHROUGH) - av_log(NULL, AV_LOG_ERROR, "Using -vsync passthrough and -r/-fpsmax can produce invalid output files\n"); - MATCH_PER_STREAM_OPT(frame_aspect_ratios, str, frame_aspect_ratio, oc, st); if (frame_aspect_ratio) { AVRational q; @@ -614,8 +610,18 @@ static OutputStream *new_video_stream(Muxer *mux, const OptionsContext *o, Input if (fps_mode) parse_and_set_vsync(fps_mode, &ost->vsync_method, ost->file_index, ost->index, 0); + if ((ost->frame_rate.num || ost->max_frame_rate.num) && + !(ost->vsync_method == VSYNC_AUTO || + ost->vsync_method == VSYNC_CFR || ost->vsync_method == VSYNC_VSCFR)) { + av_log(NULL, AV_LOG_FATAL, "One of -r/-fpsmax was specified " + "together a non-CFR -vsync/-fps_mode. This is contradictory.\n"); + exit_program(1); + } + if (ost->vsync_method == VSYNC_AUTO) { - if (!strcmp(oc->oformat->name, "avi")) { + if (ost->frame_rate.num || ost->max_frame_rate.num) { + ost->vsync_method = VSYNC_CFR; + } else if (!strcmp(oc->oformat->name, "avi")) { ost->vsync_method = VSYNC_VFR; } else { ost->vsync_method = (oc->oformat->flags & AVFMT_VARIABLE_FPS) ? diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index f3c27ed1c8..63873a7a07 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -365,7 +365,7 @@ FATE_FILTER-$(call FILTERFRAMECRC, TESTSRC2 FPS DECIMATE) += fate-filter-decimat fate-filter-decimate: CMD = framecrc -lavfi testsrc2=r=24:d=10,fps=60,decimate=5,decimate=4,decimate=3 -pix_fmt yuv420p FATE_FILTER-$(call FILTERFRAMECRC, TESTSRC2 FPS MPDECIMATE) += fate-filter-mpdecimate -fate-filter-mpdecimate: CMD = framecrc -lavfi testsrc2=r=2:d=10,fps=3,mpdecimate -r 3 -pix_fmt yuv420p +fate-filter-mpdecimate: CMD = framecrc -lavfi testsrc2=r=2:d=10,fps=3,mpdecimate -pix_fmt yuv420p FATE_FILTER-$(call FILTERFRAMECRC, FPS TESTSRC2) += $(addprefix fate-filter-fps-, up up-round-down up-round-up down down-round-down down-round-up down-eof-pass start-drop start-fill) fate-filter-fps-up: CMD = framecrc -lavfi testsrc2=r=3:d=2,fps=7 @@ -378,9 +378,8 @@ fate-filter-fps-down-eof-pass: CMD = framecrc -lavfi testsrc2=r=7:d=3.5,fps=3:eo fate-filter-fps-start-drop: CMD = framecrc -lavfi testsrc2=r=7:d=3.5,fps=3:start_time=1.5 fate-filter-fps-start-fill: CMD = framecrc -lavfi testsrc2=r=7:d=1.5,setpts=PTS+14,fps=3:start_time=1.5 -FATE_FILTER_SAMPLES-$(call FILTERDEMDEC, FPS SCALE, MOV, QTRLE) += fate-filter-fps-cfr fate-filter-fps fate-filter-fps-r +FATE_FILTER_SAMPLES-$(call FILTERDEMDEC, FPS SCALE, MOV, QTRLE) += fate-filter-fps-cfr fate-filter-fps fate-filter-fps-cfr: CMD = framecrc -auto_conversion_filters -i $(TARGET_SAMPLES)/qtrle/apple-animation-variable-fps-bug.mov -r 30 -vsync cfr -pix_fmt yuv420p -fate-filter-fps-r: CMD = framecrc -auto_conversion_filters -i $(TARGET_SAMPLES)/qtrle/apple-animation-variable-fps-bug.mov -r 30 -vf fps -pix_fmt yuv420p fate-filter-fps: CMD = framecrc -auto_conversion_filters -i $(TARGET_SAMPLES)/qtrle/apple-animation-variable-fps-bug.mov -vf fps=30 -pix_fmt yuv420p FATE_FILTER_ALPHAEXTRACT_ALPHAMERGE := $(addprefix fate-filter-alphaextract_alphamerge_, rgb yuv) diff --git a/tests/fate/video.mak b/tests/fate/video.mak index af7e77e814..d7639a3978 100644 --- a/tests/fate/video.mak +++ b/tests/fate/video.mak @@ -269,9 +269,8 @@ fate-mv-sgirle: CMD = framecrc -i $(TARGET_SAMPLES)/mv/pet-rle.movie -an FATE_VIDEO-$(call FRAMECRC, MXG, MXPEG) += fate-mxpeg fate-mxpeg: CMD = framecrc -idct simple -flags +bitexact -i $(TARGET_SAMPLES)/mxpeg/m1.mxg -an -# FIXME dropped frames in this test because of coarse timebase FATE_NUV += fate-nuv-rtjpeg -fate-nuv-rtjpeg: CMD = framecrc -idct simple -i $(TARGET_SAMPLES)/nuv/Today.nuv -an -r 1000 +fate-nuv-rtjpeg: CMD = framecrc -idct simple -i $(TARGET_SAMPLES)/nuv/Today.nuv -an -enc_time_base -1 FATE_NUV += fate-nuv-rtjpeg-fh fate-nuv-rtjpeg-fh: CMD = framecrc -idct simple -i $(TARGET_SAMPLES)/nuv/rtjpeg_frameheader.nuv -an diff --git a/tests/ref/fate/filter-fps-r b/tests/ref/fate/filter-fps-r deleted file mode 100644 index c1bc7d1547..0000000000 --- a/tests/ref/fate/filter-fps-r +++ /dev/null @@ -1,78 +0,0 @@ -#tb 0: 1/30 -#media_type 0: video -#codec_id 0: rawvideo -#dimensions 0: 112x182 -#sar 0: 0/1 -0, 0, 0, 1, 30576, 0xcdc29b3d -0, 1, 1, 1, 30576, 0xcdc29b3d -0, 2, 2, 1, 30576, 0xcdc29b3d -0, 4, 4, 1, 30576, 0xcdc29b3d -0, 5, 5, 1, 30576, 0xcdc29b3d -0, 6, 6, 1, 30576, 0x5c83656c -0, 7, 7, 1, 30576, 0x5c83656c -0, 8, 8, 1, 30576, 0x5c83656c -0, 10, 10, 1, 30576, 0x5c83656c -0, 11, 11, 1, 30576, 0x5c83656c -0, 12, 12, 1, 30576, 0x5c83656c -0, 13, 13, 1, 30576, 0x26b67f83 -0, 14, 14, 1, 30576, 0x26b67f83 -0, 16, 16, 1, 30576, 0x26b67f83 -0, 17, 17, 1, 30576, 0x26b67f83 -0, 18, 18, 1, 30576, 0x26b67f83 -0, 19, 19, 1, 30576, 0x26b67f83 -0, 20, 20, 1, 30576, 0x26b67f83 -0, 22, 22, 1, 30576, 0x26b67f83 -0, 23, 23, 1, 30576, 0x26b67f83 -0, 24, 24, 1, 30576, 0x26b67f83 -0, 25, 25, 1, 30576, 0x26b67f83 -0, 26, 26, 1, 30576, 0x26b67f83 -0, 28, 28, 1, 30576, 0x26b67f83 -0, 29, 29, 1, 30576, 0x26b67f83 -0, 30, 30, 1, 30576, 0x26b67f83 -0, 31, 31, 1, 30576, 0x26b67f83 -0, 32, 32, 1, 30576, 0x26b67f83 -0, 34, 34, 1, 30576, 0x26b67f83 -0, 35, 35, 1, 30576, 0x26b67f83 -0, 36, 36, 1, 30576, 0x26b67f83 -0, 37, 37, 1, 30576, 0x26b67f83 -0, 38, 38, 1, 30576, 0x26b67f83 -0, 40, 40, 1, 30576, 0x26b67f83 -0, 41, 41, 1, 30576, 0x26b67f83 -0, 42, 42, 1, 30576, 0x26b67f83 -0, 43, 43, 1, 30576, 0x26b67f83 -0, 44, 44, 1, 30576, 0x26b67f83 -0, 46, 46, 1, 30576, 0x26b67f83 -0, 47, 47, 1, 30576, 0x26b67f83 -0, 48, 48, 1, 30576, 0x26b67f83 -0, 49, 49, 1, 30576, 0x26b67f83 -0, 50, 50, 1, 30576, 0x26b67f83 -0, 52, 52, 1, 30576, 0x26b67f83 -0, 53, 53, 1, 30576, 0x26b67f83 -0, 54, 54, 1, 30576, 0x26b67f83 -0, 55, 55, 1, 30576, 0x26b67f83 -0, 56, 56, 1, 30576, 0x26b67f83 -0, 58, 58, 1, 30576, 0x26b67f83 -0, 59, 59, 1, 30576, 0x26b67f83 -0, 60, 60, 1, 30576, 0x26b67f83 -0, 61, 61, 1, 30576, 0x26b67f83 -0, 62, 62, 1, 30576, 0x26b67f83 -0, 64, 64, 1, 30576, 0x26b67f83 -0, 65, 65, 1, 30576, 0x26b67f83 -0, 66, 66, 1, 30576, 0x26b67f83 -0, 67, 67, 1, 30576, 0x26b67f83 -0, 68, 68, 1, 30576, 0x26b67f83 -0, 70, 70, 1, 30576, 0x26b67f83 -0, 71, 71, 1, 30576, 0x26b67f83 -0, 72, 72, 1, 30576, 0x26b67f83 -0, 73, 73, 1, 30576, 0xa2fcd06f -0, 74, 74, 1, 30576, 0xa2fcd06f -0, 76, 76, 1, 30576, 0xa2fcd06f -0, 77, 77, 1, 30576, 0xa2fcd06f -0, 78, 78, 1, 30576, 0xa2fcd06f -0, 79, 79, 1, 30576, 0xa2fcd06f -0, 80, 80, 1, 30576, 0xa2fcd06f -0, 82, 82, 1, 30576, 0xd4150aad -0, 83, 83, 1, 30576, 0xd4150aad -0, 84, 84, 1, 30576, 0xd4150aad -0, 85, 85, 1, 30576, 0xd4150aad -0, 86, 86, 1, 30576, 0xd4150aad diff --git a/tests/ref/fate/nuv-rtjpeg b/tests/ref/fate/nuv-rtjpeg index bc5af1ca22..d6093e78d8 100644 --- a/tests/ref/fate/nuv-rtjpeg +++ b/tests/ref/fate/nuv-rtjpeg @@ -3,11 +3,11 @@ #codec_id 0: rawvideo #dimensions 0: 640x480 #sar 0: 1/1 -0, 118, 118, 1, 460800, 0x54aedafe -0, 152, 152, 1, 460800, 0xb7aa8b56 -0, 177, 177, 1, 460800, 0x283ea3b5 -0, 202, 202, 1, 460800, 0x283ea3b5 -0, 235, 235, 1, 460800, 0x10e577de -0, 269, 269, 1, 460800, 0x4e091ee2 -0, 302, 302, 1, 460800, 0x2ea88828 -0, 335, 335, 1, 460800, 0x4b7f4df0 +0, 118, 118, 33, 460800, 0x54aedafe +0, 152, 152, 33, 460800, 0xb7aa8b56 +0, 177, 177, 33, 460800, 0x283ea3b5 +0, 202, 202, 33, 460800, 0x283ea3b5 +0, 235, 235, 33, 460800, 0x10e577de +0, 269, 269, 33, 460800, 0x4e091ee2 +0, 302, 302, 33, 460800, 0x2ea88828 +0, 335, 335, 33, 460800, 0x4b7f4df0 -- 2.35.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [FFmpeg-devel] [PATCH 8/8] fftools/ffmpeg: always generate CFR output when -r is used 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 8/8] fftools/ffmpeg: always generate CFR output when -r is used Anton Khirnov @ 2023-01-04 17:37 ` Paul B Mahol 2023-01-04 17:41 ` Anton Khirnov 0 siblings, 1 reply; 12+ messages in thread From: Paul B Mahol @ 2023-01-04 17:37 UTC (permalink / raw) To: FFmpeg development discussions and patches On Wed, Jan 4, 2023 at 5:46 PM Anton Khirnov <anton@khirnov.net> wrote: > Current code may, depending on the muxer, decide to use VSYNC_VFR tagged > with the specified framerate, without actually performing framerate > conversion. This is clearly wrong and against the documentation, which > states unambiguously that -r should produce CFR output for video > encoding. > > FATE test changes: > * nuv-rtjpeg: replace -r with '-enc_time_base -1', which keeps the > original timebase. Output frames are now produced with proper > durations. > * filter-mpdecimate: just drop the -r option, it is unnecessary > * filter-fps-r: remove, this test makes no sense and actually > produces broken VFR output (with incorrect frame durations). > With this patch or even before? > --- > fftools/ffmpeg_mux_init.c | 16 +++++--- > tests/fate/filter-video.mak | 5 +-- > tests/fate/video.mak | 3 +- > tests/ref/fate/filter-fps-r | 78 ------------------------------------- > tests/ref/fate/nuv-rtjpeg | 16 ++++---- > 5 files changed, 22 insertions(+), 96 deletions(-) > delete mode 100644 tests/ref/fate/filter-fps-r > > diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c > index 0280759b05..9eea8639dc 100644 > --- a/fftools/ffmpeg_mux_init.c > +++ b/fftools/ffmpeg_mux_init.c > @@ -443,10 +443,6 @@ static OutputStream *new_video_stream(Muxer *mux, > const OptionsContext *o, Input > exit_program(1); > } > > - if ((frame_rate || max_frame_rate) && > - video_sync_method == VSYNC_PASSTHROUGH) > - av_log(NULL, AV_LOG_ERROR, "Using -vsync passthrough and > -r/-fpsmax can produce invalid output files\n"); > - > MATCH_PER_STREAM_OPT(frame_aspect_ratios, str, frame_aspect_ratio, > oc, st); > if (frame_aspect_ratio) { > AVRational q; > @@ -614,8 +610,18 @@ static OutputStream *new_video_stream(Muxer *mux, > const OptionsContext *o, Input > if (fps_mode) > parse_and_set_vsync(fps_mode, &ost->vsync_method, > ost->file_index, ost->index, 0); > > + if ((ost->frame_rate.num || ost->max_frame_rate.num) && > + !(ost->vsync_method == VSYNC_AUTO || > + ost->vsync_method == VSYNC_CFR || ost->vsync_method == > VSYNC_VSCFR)) { > + av_log(NULL, AV_LOG_FATAL, "One of -r/-fpsmax was specified " > + "together a non-CFR -vsync/-fps_mode. This is > contradictory.\n"); > + exit_program(1); > + } > + > if (ost->vsync_method == VSYNC_AUTO) { > - if (!strcmp(oc->oformat->name, "avi")) { > + if (ost->frame_rate.num || ost->max_frame_rate.num) { > + ost->vsync_method = VSYNC_CFR; > + } else if (!strcmp(oc->oformat->name, "avi")) { > ost->vsync_method = VSYNC_VFR; > } else { > ost->vsync_method = (oc->oformat->flags & > AVFMT_VARIABLE_FPS) ? > diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak > index f3c27ed1c8..63873a7a07 100644 > --- a/tests/fate/filter-video.mak > +++ b/tests/fate/filter-video.mak > @@ -365,7 +365,7 @@ FATE_FILTER-$(call FILTERFRAMECRC, TESTSRC2 FPS > DECIMATE) += fate-filter-decimat > fate-filter-decimate: CMD = framecrc -lavfi > testsrc2=r=24:d=10,fps=60,decimate=5,decimate=4,decimate=3 -pix_fmt yuv420p > > FATE_FILTER-$(call FILTERFRAMECRC, TESTSRC2 FPS MPDECIMATE) += > fate-filter-mpdecimate > -fate-filter-mpdecimate: CMD = framecrc -lavfi > testsrc2=r=2:d=10,fps=3,mpdecimate -r 3 -pix_fmt yuv420p > +fate-filter-mpdecimate: CMD = framecrc -lavfi > testsrc2=r=2:d=10,fps=3,mpdecimate -pix_fmt yuv420p > > FATE_FILTER-$(call FILTERFRAMECRC, FPS TESTSRC2) += $(addprefix > fate-filter-fps-, up up-round-down up-round-up down down-round-down > down-round-up down-eof-pass start-drop start-fill) > fate-filter-fps-up: CMD = framecrc -lavfi testsrc2=r=3:d=2,fps=7 > @@ -378,9 +378,8 @@ fate-filter-fps-down-eof-pass: CMD = framecrc -lavfi > testsrc2=r=7:d=3.5,fps=3:eo > fate-filter-fps-start-drop: CMD = framecrc -lavfi > testsrc2=r=7:d=3.5,fps=3:start_time=1.5 > fate-filter-fps-start-fill: CMD = framecrc -lavfi > testsrc2=r=7:d=1.5,setpts=PTS+14,fps=3:start_time=1.5 > > -FATE_FILTER_SAMPLES-$(call FILTERDEMDEC, FPS SCALE, MOV, QTRLE) += > fate-filter-fps-cfr fate-filter-fps fate-filter-fps-r > +FATE_FILTER_SAMPLES-$(call FILTERDEMDEC, FPS SCALE, MOV, QTRLE) += > fate-filter-fps-cfr fate-filter-fps > fate-filter-fps-cfr: CMD = framecrc -auto_conversion_filters -i > $(TARGET_SAMPLES)/qtrle/apple-animation-variable-fps-bug.mov -r 30 -vsync > cfr -pix_fmt yuv420p > -fate-filter-fps-r: CMD = framecrc -auto_conversion_filters -i > $(TARGET_SAMPLES)/qtrle/apple-animation-variable-fps-bug.mov -r 30 -vf fps > -pix_fmt yuv420p > fate-filter-fps: CMD = framecrc -auto_conversion_filters -i > $(TARGET_SAMPLES)/qtrle/apple-animation-variable-fps-bug.mov -vf fps=30 > -pix_fmt yuv420p > > FATE_FILTER_ALPHAEXTRACT_ALPHAMERGE := $(addprefix > fate-filter-alphaextract_alphamerge_, rgb yuv) > diff --git a/tests/fate/video.mak b/tests/fate/video.mak > index af7e77e814..d7639a3978 100644 > --- a/tests/fate/video.mak > +++ b/tests/fate/video.mak > @@ -269,9 +269,8 @@ fate-mv-sgirle: CMD = framecrc -i > $(TARGET_SAMPLES)/mv/pet-rle.movie -an > FATE_VIDEO-$(call FRAMECRC, MXG, MXPEG) += fate-mxpeg > fate-mxpeg: CMD = framecrc -idct simple -flags +bitexact -i > $(TARGET_SAMPLES)/mxpeg/m1.mxg -an > > -# FIXME dropped frames in this test because of coarse timebase > FATE_NUV += fate-nuv-rtjpeg > -fate-nuv-rtjpeg: CMD = framecrc -idct simple -i > $(TARGET_SAMPLES)/nuv/Today.nuv -an -r 1000 > +fate-nuv-rtjpeg: CMD = framecrc -idct simple -i > $(TARGET_SAMPLES)/nuv/Today.nuv -an -enc_time_base -1 > > FATE_NUV += fate-nuv-rtjpeg-fh > fate-nuv-rtjpeg-fh: CMD = framecrc -idct simple -i > $(TARGET_SAMPLES)/nuv/rtjpeg_frameheader.nuv -an > diff --git a/tests/ref/fate/filter-fps-r b/tests/ref/fate/filter-fps-r > deleted file mode 100644 > index c1bc7d1547..0000000000 > --- a/tests/ref/fate/filter-fps-r > +++ /dev/null > @@ -1,78 +0,0 @@ > -#tb 0: 1/30 > -#media_type 0: video > -#codec_id 0: rawvideo > -#dimensions 0: 112x182 > -#sar 0: 0/1 > -0, 0, 0, 1, 30576, 0xcdc29b3d > -0, 1, 1, 1, 30576, 0xcdc29b3d > -0, 2, 2, 1, 30576, 0xcdc29b3d > -0, 4, 4, 1, 30576, 0xcdc29b3d > -0, 5, 5, 1, 30576, 0xcdc29b3d > -0, 6, 6, 1, 30576, 0x5c83656c > -0, 7, 7, 1, 30576, 0x5c83656c > -0, 8, 8, 1, 30576, 0x5c83656c > -0, 10, 10, 1, 30576, 0x5c83656c > -0, 11, 11, 1, 30576, 0x5c83656c > -0, 12, 12, 1, 30576, 0x5c83656c > -0, 13, 13, 1, 30576, 0x26b67f83 > -0, 14, 14, 1, 30576, 0x26b67f83 > -0, 16, 16, 1, 30576, 0x26b67f83 > -0, 17, 17, 1, 30576, 0x26b67f83 > -0, 18, 18, 1, 30576, 0x26b67f83 > -0, 19, 19, 1, 30576, 0x26b67f83 > -0, 20, 20, 1, 30576, 0x26b67f83 > -0, 22, 22, 1, 30576, 0x26b67f83 > -0, 23, 23, 1, 30576, 0x26b67f83 > -0, 24, 24, 1, 30576, 0x26b67f83 > -0, 25, 25, 1, 30576, 0x26b67f83 > -0, 26, 26, 1, 30576, 0x26b67f83 > -0, 28, 28, 1, 30576, 0x26b67f83 > -0, 29, 29, 1, 30576, 0x26b67f83 > -0, 30, 30, 1, 30576, 0x26b67f83 > -0, 31, 31, 1, 30576, 0x26b67f83 > -0, 32, 32, 1, 30576, 0x26b67f83 > -0, 34, 34, 1, 30576, 0x26b67f83 > -0, 35, 35, 1, 30576, 0x26b67f83 > -0, 36, 36, 1, 30576, 0x26b67f83 > -0, 37, 37, 1, 30576, 0x26b67f83 > -0, 38, 38, 1, 30576, 0x26b67f83 > -0, 40, 40, 1, 30576, 0x26b67f83 > -0, 41, 41, 1, 30576, 0x26b67f83 > -0, 42, 42, 1, 30576, 0x26b67f83 > -0, 43, 43, 1, 30576, 0x26b67f83 > -0, 44, 44, 1, 30576, 0x26b67f83 > -0, 46, 46, 1, 30576, 0x26b67f83 > -0, 47, 47, 1, 30576, 0x26b67f83 > -0, 48, 48, 1, 30576, 0x26b67f83 > -0, 49, 49, 1, 30576, 0x26b67f83 > -0, 50, 50, 1, 30576, 0x26b67f83 > -0, 52, 52, 1, 30576, 0x26b67f83 > -0, 53, 53, 1, 30576, 0x26b67f83 > -0, 54, 54, 1, 30576, 0x26b67f83 > -0, 55, 55, 1, 30576, 0x26b67f83 > -0, 56, 56, 1, 30576, 0x26b67f83 > -0, 58, 58, 1, 30576, 0x26b67f83 > -0, 59, 59, 1, 30576, 0x26b67f83 > -0, 60, 60, 1, 30576, 0x26b67f83 > -0, 61, 61, 1, 30576, 0x26b67f83 > -0, 62, 62, 1, 30576, 0x26b67f83 > -0, 64, 64, 1, 30576, 0x26b67f83 > -0, 65, 65, 1, 30576, 0x26b67f83 > -0, 66, 66, 1, 30576, 0x26b67f83 > -0, 67, 67, 1, 30576, 0x26b67f83 > -0, 68, 68, 1, 30576, 0x26b67f83 > -0, 70, 70, 1, 30576, 0x26b67f83 > -0, 71, 71, 1, 30576, 0x26b67f83 > -0, 72, 72, 1, 30576, 0x26b67f83 > -0, 73, 73, 1, 30576, 0xa2fcd06f > -0, 74, 74, 1, 30576, 0xa2fcd06f > -0, 76, 76, 1, 30576, 0xa2fcd06f > -0, 77, 77, 1, 30576, 0xa2fcd06f > -0, 78, 78, 1, 30576, 0xa2fcd06f > -0, 79, 79, 1, 30576, 0xa2fcd06f > -0, 80, 80, 1, 30576, 0xa2fcd06f > -0, 82, 82, 1, 30576, 0xd4150aad > -0, 83, 83, 1, 30576, 0xd4150aad > -0, 84, 84, 1, 30576, 0xd4150aad > -0, 85, 85, 1, 30576, 0xd4150aad > -0, 86, 86, 1, 30576, 0xd4150aad > diff --git a/tests/ref/fate/nuv-rtjpeg b/tests/ref/fate/nuv-rtjpeg > index bc5af1ca22..d6093e78d8 100644 > --- a/tests/ref/fate/nuv-rtjpeg > +++ b/tests/ref/fate/nuv-rtjpeg > @@ -3,11 +3,11 @@ > #codec_id 0: rawvideo > #dimensions 0: 640x480 > #sar 0: 1/1 > -0, 118, 118, 1, 460800, 0x54aedafe > -0, 152, 152, 1, 460800, 0xb7aa8b56 > -0, 177, 177, 1, 460800, 0x283ea3b5 > -0, 202, 202, 1, 460800, 0x283ea3b5 > -0, 235, 235, 1, 460800, 0x10e577de > -0, 269, 269, 1, 460800, 0x4e091ee2 > -0, 302, 302, 1, 460800, 0x2ea88828 > -0, 335, 335, 1, 460800, 0x4b7f4df0 > +0, 118, 118, 33, 460800, 0x54aedafe > +0, 152, 152, 33, 460800, 0xb7aa8b56 > +0, 177, 177, 33, 460800, 0x283ea3b5 > +0, 202, 202, 33, 460800, 0x283ea3b5 > +0, 235, 235, 33, 460800, 0x10e577de > +0, 269, 269, 33, 460800, 0x4e091ee2 > +0, 302, 302, 33, 460800, 0x2ea88828 > +0, 335, 335, 33, 460800, 0x4b7f4df0 > -- > 2.35.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [FFmpeg-devel] [PATCH 8/8] fftools/ffmpeg: always generate CFR output when -r is used 2023-01-04 17:37 ` Paul B Mahol @ 2023-01-04 17:41 ` Anton Khirnov 0 siblings, 0 replies; 12+ messages in thread From: Anton Khirnov @ 2023-01-04 17:41 UTC (permalink / raw) To: FFmpeg development discussions and patches Quoting Paul B Mahol (2023-01-04 18:37:31) > On Wed, Jan 4, 2023 at 5:46 PM Anton Khirnov <anton@khirnov.net> wrote: > > > Current code may, depending on the muxer, decide to use VSYNC_VFR tagged > > with the specified framerate, without actually performing framerate > > conversion. This is clearly wrong and against the documentation, which > > states unambiguously that -r should produce CFR output for video > > encoding. > > > > FATE test changes: > > * nuv-rtjpeg: replace -r with '-enc_time_base -1', which keeps the > > original timebase. Output frames are now produced with proper > > durations. > > * filter-mpdecimate: just drop the -r option, it is unnecessary > > * filter-fps-r: remove, this test makes no sense and actually > > produces broken VFR output (with incorrect frame durations). > > > > With this patch or even before? With current master, so without the patch. After the patch it starts producing proper CFR, but is then redundant with fate-filter-fps-cfr. -- Anton Khirnov _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-01-05 11:10 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-01-04 16:42 [FFmpeg-devel] [PATCH 1/8] doc/ffmpeg.texi: drop a non-existent option Anton Khirnov 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 2/8] fftools/ffmpeg: stop using AVCodecContext.sample_rate in decode_audio() Anton Khirnov 2023-01-05 0:46 ` Michael Niedermayer 2023-01-05 11:09 ` Anton Khirnov 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 3/8] fftools/ffmpeg: fix stream id in an error message Anton Khirnov 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 4/8] fftools/ffmpeg: rename a variable to be more descriptive Anton Khirnov 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 5/8] fftools/ffmpeg: move video frame dup/drop logic into its own function Anton Khirnov 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 6/8] fftools/ffmpeg: reindent after previous commit Anton Khirnov 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 7/8] doc/ffmpeg: improve -r documentation Anton Khirnov 2023-01-04 16:42 ` [FFmpeg-devel] [PATCH 8/8] fftools/ffmpeg: always generate CFR output when -r is used Anton Khirnov 2023-01-04 17:37 ` Paul B Mahol 2023-01-04 17:41 ` Anton Khirnov
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git