From patchwork Wed Jan 4 16:42:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39870 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp8942458pzb; Wed, 4 Jan 2023 08:46:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXtOBP1BSWGbhp1QqGK2K55im4UIcnFwFHVb4R1a2SWy2w6+8KVF7qGvx8LxSupBT2W+IXCw X-Received: by 2002:aa7:cf94:0:b0:46b:6214:44c8 with SMTP id z20-20020aa7cf94000000b0046b621444c8mr39488741edx.39.1672850787274; Wed, 04 Jan 2023 08:46:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672850787; cv=none; d=google.com; s=arc-20160816; b=LCm9O/Gw8W6sLeqH010AP4lT0SejWmX3umBCMjgiglNCwfRRCvEE70t8QVfnN36Zt9 gac3ADGXCWfrBDlSR6Q2M4eqpolMwG0xyGKW9W7kENK7VdCaT9LQcEAQotcOsO+lgiLW wjeulyAgTC9GA2XYjhFW39FTNOAxhT6AdPaH264pwQKs5jduIOreiDXLU76B3dUMH1VQ DbQBlMi6HWChS1UjBJU2lfP2uvTuH7fRB8EQBj56KcolJ4SRe5AaUWzGWRP4J8LR8+jf 1xvo8fsOKI+xZTCkF4G31+LaB0yKERa0Q02sFcqIsTtd4+sIjGYDF/YPgrBqHQ3a9Hq5 v02g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=1jGPnjySKW0X+Oe00C54ePyhkMOeiRXup42Q0hu9JqY=; b=q+9KGBqz1cbnoxWlk+7nSI6QY5HRmrNDnHDbkkmJgk1h/5IBYwQdOCxlAUiZmltRqE IAyKluRFoJtleI3wyt0rk27kzZolhfOBQacs1V4r9TwFHVpZtLeoUym4LFeWJvRm0kBZ je/zWmYTv1x5cehIG/0LLdSttMPmbeXsUQsVUXlrAJkw6X2Kz1TLPXJobHFEllQYxSP9 tsrx3mMs23GrAY0GdlGTPG7YEo4LPdjFdcEMp1G5UrmQVg+FDTOT8PVfNuVLLf44g8wB c53cGmLLOc1YF4egK1kZp5zRuAx0pex6Q5T1U22JqIhRU8X583RnsZGyiyLZRF7QEdhk r0Aw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n9-20020a50cc49000000b0048321d887b5si8238137edi.516.2023.01.04.08.46.26; Wed, 04 Jan 2023 08:46:27 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4BF1368BCEB; Wed, 4 Jan 2023 18:45:32 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D255368BD00 for ; Wed, 4 Jan 2023 18:45:24 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 2E2E12405EC for ; Wed, 4 Jan 2023 17:45:23 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id gPs2orA1CKEw for ; Wed, 4 Jan 2023 17:45:22 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id B67F92406C7 for ; Wed, 4 Jan 2023 17:45:18 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id CC6FB3A03EF for ; Wed, 4 Jan 2023 17:45:10 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Jan 2023 17:42:46 +0100 Message-Id: <20230104164246.6133-8-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230104164246.6133-1-anton@khirnov.net> References: <20230104164246.6133-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 8/8] fftools/ffmpeg: always generate CFR output when -r is used X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Irx3Qu/gPiw1 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