From patchwork Wed Jan 4 16:42:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39864 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp8941824pzb; Wed, 4 Jan 2023 08:45:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXsHyGJN/LHwFAWWu/7KWnMxwpDRcZFroSOccWlRps+QcgWuYJwv95aOFue6RHgG5LCiUmMn X-Received: by 2002:a17:906:5e04:b0:7c0:e803:4ebb with SMTP id n4-20020a1709065e0400b007c0e8034ebbmr40336669eju.70.1672850730543; Wed, 04 Jan 2023 08:45:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672850730; cv=none; d=google.com; s=arc-20160816; b=M9f4NauBoI5F8rVchER7He7VsEINj78KpFNks/L/YGFt1khE8ZJ4mNw4yjBLzt9zda ICuuOgSUhkT7KFyHl4bqG91ryyOABf/qzI3DuiaCJVBCLbH7397S6d+LZOyFg/KtDIGi C/8nsTbKbPYYrA71SGp2GuMvZW1p0vwceZfPElSgz9w9oa+AzQghajusPU3MY6isNIWr OvORoHIB2lAGbHfbGUbyk8m4vaASMSkpAXmr7yxqSaH2q0o1R3BP5Lal3+1l8P0450gH gkD2gz98pQ3CyQ+TlPwcSqan7TtMTGW286wrmsLx5yTQFCiLyB/NTM+wYgCZJT5ZhR25 Qt5w== 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:message-id:date:to:from :delivered-to; bh=Ve/1vXeNMn9VDrpuu9nwnw2J/EJHSq0uJ5K3gSouJu8=; b=qJhG3OsXOxBG+OMFQYhU2dyI0bvHUkDShlvjGM1GqfWBk8QR2dZbJcPFBqLuBA/48m 8uVETx8y+y/HoxdW50pcFDrqOUYcVe+AVmw3jIUQ3Tt9W9A445H12lgc6nC4TDUvu0lb D5jmYdqvsqWeEierkAFnK9M9wbECR2Re2QJhxNzbhWx+5qZTKHhYhtj+8tqhS6D2i4A0 QzSwtARIOaLVad4bOYhAw0lkzMx5Ip+Wl7bPX9ezct+IV7HV8VjJgOUvIOjfBaWIeEgO PcfvljSfDTComCeAcXYlZIEyawChTjxQzfdV8fMO1k6MeHG6lxmKsdxhenb7TAcOONMX 1YXA== 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 gt20-20020a1709072d9400b007c0fa2e0f9fsi33366578ejc.133.2023.01.04.08.45.30; Wed, 04 Jan 2023 08:45:30 -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 74C2568BCCF; Wed, 4 Jan 2023 18:45:26 +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 94DA368B109 for ; Wed, 4 Jan 2023 18:45:19 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 1A9772406CA for ; Wed, 4 Jan 2023 17:45:19 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id C0cqK-vXJkXO for ; Wed, 4 Jan 2023 17:45:18 +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 8A6EE2400F5 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 7984D3A0101 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:39 +0100 Message-Id: <20230104164246.6133-1-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/8] doc/ffmpeg.texi: drop a non-existent option 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: r+/iJbmFu/Cr -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}. From patchwork Wed Jan 4 16:42:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39867 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp8942102pzb; Wed, 4 Jan 2023 08:45:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXtwKZxSE/jr9kf/cbgoyGemAvgsL91OZ88iCcZRD0pN6A6HwHc81y66c7RygE41yCIOnFbr X-Received: by 2002:a17:907:3e0c:b0:7c0:f90f:163d with SMTP id hp12-20020a1709073e0c00b007c0f90f163dmr54748310ejc.11.1672850757742; Wed, 04 Jan 2023 08:45:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672850757; cv=none; d=google.com; s=arc-20160816; b=xs9wLZ48ahVUL/c+p62/01HqDCT4afa7qgAUsQW8anPqtPBZM6h8Maw7p0ssTxIILt mkx3pwe4sOrdJR7pLacUH8jC5p+fsoZ2cKjfHX54ib1K7hdNywgOX6kzvfSKG50O9/1n xVV8L5OjUXMUYZ2atjEk0KADVyxDq4ky71vBL0VzeaHg7MjoBCgbfbM/U6m7aDOU7DkG Z5NaiGzAs666H4yGT+v4FDyORjhkoi5WnM4vFndsHZzaXTcQXGZEea/k4hrOlgM36Dn/ rIXBt+Q7ucdiTeQu9E+grliR0MiWSLVDPUsC3utA2rFgYMZaOutETWp6aRuNEGSgfcO4 3LpA== 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=CWkOkJxj5GJyiYMb16B9F392Yqtnxnjb7W0IM8l0F8U=; b=zhNPj+sul8aQSQePyMii8KvF77gdj9dVOEcSpaZoRlmeEy5gRhFAtDt9qZ5qPXpMk8 IXXqo80FJ+IgzWs10CLxbrko7C7LkmNnyzSLCcVFmFCds8h3rAcbEjvY6V4ZxvALcaQ/ +NZqVM5Lb6+hUUFeuRy4b7eZGie1suEREMntprNUdiryJj3nA2584GxKDZnf3SZdeDMZ fuEYjLlJsb9//bN4/5UhmIztix76JtNWBnnqKwci5CBd7n/AMX8povjpuBVDIFI7gtoF sphWXsmEwTjzkYS2rbzBh3QKkrrDX9oB/g/eRAFYRve2yntD1YgXQvasWXFJrJhnj/7J 8e2Q== 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 i10-20020a170906264a00b007aea5ae3956si21999322ejc.820.2023.01.04.08.45.57; Wed, 04 Jan 2023 08:45:57 -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 3F55B68BCF7; Wed, 4 Jan 2023 18:45:29 +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 4A71D68BCCF for ; Wed, 4 Jan 2023 18:45:21 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 0604A240591 for ; Wed, 4 Jan 2023 17:45:21 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ZSJCERcr2Xw9 for ; Wed, 4 Jan 2023 17:45:18 +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 8E443240499 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 87B053A0344 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:40 +0100 Message-Id: <20230104164246.6133-2-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 2/8] fftools/ffmpeg: stop using AVCodecContext.sample_rate in decode_audio() 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: aSc9TNXBUPAJ 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); From patchwork Wed Jan 4 16:42:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39866 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp8942015pzb; Wed, 4 Jan 2023 08:45:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXsWQMyx9U4dmsNMTZl+tu3sAktrJQkcxED/qEylcE0SBgyBZX+qtDZapvGSiBqXdBpJKN2T X-Received: by 2002:aa7:d40b:0:b0:48d:778:e6d6 with SMTP id z11-20020aa7d40b000000b0048d0778e6d6mr11696121edq.19.1672850748959; Wed, 04 Jan 2023 08:45:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672850748; cv=none; d=google.com; s=arc-20160816; b=XC2Iel8m6qK6AROPD4ICpYmx9ACn6XiW8nhYMK6bPb1tqoSnHVMDsGeeIIwCQJ2cBw /EuejDubgvYPi197b7UWOfw3Q1DGJOOnmk5f6UGAcCazzG96DGVSm/8Jc3JablDL6OSr yL1jB9CeeWz1LnbAde3lloizvEz/xAyjVM0v3I4gaZkCl9Pa4a1eFskrpSAjRfy0bVoJ vtTPDSCdtk1F6uJBz3YEfSHcMAO/ZCX1k4kdgJHiU6a4YfwbsmzXS/ly+5uXYZOg20Eb +0trWamQRXH5QqwoEeG6Pbn3ry0PViB4VmWFOib6qRpLWIv+O9mEGYanNwC9ZeLOPCpW 0k3A== 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=5gb9KiPjMc1s1HfG2l9LhOI0zBZwHUd4g+lwVqZwevk=; b=MEjC5yoGDMRYmZDmOCs5VtsBL8QgxFZs2mcccKxcOQCjA69hNJnDOwynK+njnVQL/J OkrY9jdUXXyG2R44Ks/rYBkb15WSqE3GCrRxEMK5irB5GpDooYy/fRVUSM8KIIbAUhgw 8gy8qA4AhT3Zv95zg2gZTxBIra3YGzydL0Zjh96x0zB2zsqJbQ+dQwaNIqpc2vLw2oXX +9BhGIqYs08k7Mc3+/FVHolYrRjtlUqTVyH2uHWKQhflBc680+NePp75P8yDSR/dRzWc fFjQpI2048rWjepHK7IGAiK0eZkNXq9KuB/+vG1bD5SwaLBCZh63iVfzQvJGf3vbbfGh ytng== 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 ek8-20020a056402370800b00485d0d6ea57si21310822edb.619.2023.01.04.08.45.48; Wed, 04 Jan 2023 08:45:48 -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 56C5968BCE9; Wed, 4 Jan 2023 18:45:28 +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 978EA68B1AD for ; Wed, 4 Jan 2023 18:45:20 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 5D41D2404F7 for ; Wed, 4 Jan 2023 17:45:20 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Hv3iPHKEhhmo for ; Wed, 4 Jan 2023 17:45:19 +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 923EC240591 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 92C393A034A 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:41 +0100 Message-Id: <20230104164246.6133-3-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 3/8] fftools/ffmpeg: fix stream id in an error message. 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: fIaxUTAslC4l 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); } } From patchwork Wed Jan 4 16:42:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39871 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp8942606pzb; Wed, 4 Jan 2023 08:46:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXvlY+avx4OnwkXVcA1+uWpJcA16uWxqjSb4zpcEGDi354nYyPigXfMCMfQpfWB6sofDXzjP X-Received: by 2002:a17:907:cb85:b0:7c0:f216:cc14 with SMTP id un5-20020a170907cb8500b007c0f216cc14mr41800447ejc.11.1672850797237; Wed, 04 Jan 2023 08:46:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672850797; cv=none; d=google.com; s=arc-20160816; b=disXmlGnW2sT7KvGKizWcn5iAqvDhTurzFNyj+xfNS0J1GIc5GwKW2hPvFTu1oumkx tQx++3mXL+dgBxhohqlI7rB684KAQ48j8sPB1V1WpH7CRPnB+PHpvNIUKXzFMwe+NZxf X1awVd/Bs2HmqHXVhECvNBuJDmjqIBqQoaqPqqqjglyDL0sT0T9ZDInpzNTdiAFbmF6v VaFimfrNq49YmQAccB8tGgDw0dRKlG0RMPQMBwzgYrlZeGd+JxVb0g30zZ+JnNX5VqWO UyGJjQKRiKIaGMf0YW2kAoArc3comWfJkWJds3sVobN025iedRGApanUbpGhqdDNUPq1 90gA== 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=+yAyf8hy2HdgUhR/kxnIM9vulXB7FDl6oPsnFMFuFeo=; b=n0bucQg4xrGz7zM5GIc8XXCkWtc45ezZt4XNo9aZG8lcT0M+ALTEX9KWz76eexVbs8 8gbG2PZoM/IXbSJaJUT3pPGdECyxtBN9btE/XNcmNPQkyXnfdNIWbTNbshsdE6/1PlKn JrlY68g3Wt8P2JIFipscStqejzf2aX3XCa/WpJrNgTrmMNAxNNZRemF5lJJmw9oOm+rG IqRUz23h8qRFfpYxzU+UHgJvzQ0KxCZO1R8OL5TLDheuFwlueykcB6HHSMTAsIsA0Tjc OjW0Qq8ZhCdUzEQLcPfPdf9Re1xU8OvydYQ2f0+belkAR1Z6MrcRALKgfICznLf9u4D0 E2vw== 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 v3-20020a056402348300b0048edf59946fsi3862093edc.19.2023.01.04.08.46.36; Wed, 04 Jan 2023 08:46:37 -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 4D61768BD1D; Wed, 4 Jan 2023 18:45:33 +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 5AC1368BD09 for ; Wed, 4 Jan 2023 18:45:25 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 59D5D2406C7 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 GzfEiSzj6qhX for ; Wed, 4 Jan 2023 17:45:21 +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 91D492404F8 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 9E3A73A034C 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:42 +0100 Message-Id: <20230104164246.6133-4-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 4/8] fftools/ffmpeg: rename a variable to be more descriptive 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: 8cJRnQkNpXWX --- 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; From patchwork Wed Jan 4 16:42:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39865 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp8941936pzb; Wed, 4 Jan 2023 08:45:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXvLf5eYdBcDINdVk3RijarRNPIdIwVTIN6+rtVyabCPorws0GdmE+Gjd4MOegpLYIqyrMs3 X-Received: by 2002:aa7:c30b:0:b0:47b:a6e:6ba5 with SMTP id l11-20020aa7c30b000000b0047b0a6e6ba5mr40558238edq.12.1672850740605; Wed, 04 Jan 2023 08:45:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672850740; cv=none; d=google.com; s=arc-20160816; b=LuRN49mZ3zKgav4y7x69O074a9Yw2NjhaQV1BWIBKlrOwDhRZRC1Tr4Q6pvaN2PEdp 0d+ewakIInDt8LsTYymQAtIsEfpjeF5CBHN8lXmnd0KGQivvZD//5WxpkYBl1NLXIaNE jAcF5fcN65grmWGVbRFq7CHh33DzkEklAaz475ov171niaAshujWU9qFE6MxiC4H0c+l EqKaPFvKMsXuYyTlhxtyaNRGgywEaz4ODhJ/Z7FonBllajLL1RIjJTYbUrV7v8AH40Zi WEQItKYF0UWrwiaXhpWFDePANW82QvmQ/51D9IlyW/PPXwQET1DO3E4A/hKEKuTaHBtZ 1L2Q== 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=aas9haCkYENhktI0M3PeXoHgmLkXlcd5YQH7KRjQKlE=; b=VV3pu/TdJ44PmJ8mtAVg8hfyyfJu4r30YaP1KMdMZZhvstupo3p91GFOfpzlYeNsDl 3EuLq6s6sguDK5wjPiIp6vjquyVqRYsdVmnaPSVOIiDg/K+dsHjcY6ewO4tQX3IFcBOn 5fCDwxdPibk4Q+/niNOzh98xPsUI9IhcJADdfdyU0WCZO5fpo3lO/11KFYfVc3lYjkG+ sa/nvwVB6kXSNNiHl1jHIMUssNJ02E24O8i3LF7dkxhNFN7TwO1iARzv/QhIYuKhZdUh FZEATKAGiXU079TX/PQhF3htzmGqr+CarTp4CkzO2HkB6SoCo8efJZeejka0PIjVPP3k 5dyg== 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 z8-20020a05640235c800b0048ef14a74e4si3395189edc.141.2023.01.04.08.45.39; Wed, 04 Jan 2023 08:45:40 -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 7669B68B109; Wed, 4 Jan 2023 18:45:27 +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 22A9968B109 for ; Wed, 4 Jan 2023 18:45:20 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id DC9B02400F5 for ; Wed, 4 Jan 2023 17:45:19 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id cBtVWJ8krGzy for ; Wed, 4 Jan 2023 17:45:19 +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 9034E2404F7 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 A9FC53A0354 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:43 +0100 Message-Id: <20230104164246.6133-5-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 5/8] fftools/ffmpeg: move video frame dup/drop logic into its own function 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: MPF0U7QfygGb --- 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, From patchwork Wed Jan 4 16:42:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39869 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp8942324pzb; Wed, 4 Jan 2023 08:46:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXuBsRE1nVvzTwxn1FmAmD8XIkBkiaKAyGCQnH577o5j72g5228fWRVhWfA3oX6cQWdLidhw X-Received: by 2002:a50:d5d7:0:b0:46f:860d:3ff1 with SMTP id g23-20020a50d5d7000000b0046f860d3ff1mr42644142edj.7.1672850776806; Wed, 04 Jan 2023 08:46:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672850776; cv=none; d=google.com; s=arc-20160816; b=IulYyNKQ4KJbqcCGxOsqDvjnyapYjrLBwYpaAh3InzJFvak3OJXxZLcnGb33CH/nFv GBYzDNUvcL6Qo0QVXDHBv9x8yVmw60vTRAD1EL8YfAvL1XSeiuLWnQfssTikUUFyCjUX qYTmjF51BYKuomh4HL6+crHdfc77J68v0oy48kHTaTqTbQnQNi7sPf29F4YG8mpuXWKY fnPLPbTJ7pK1VHwA5otHtyzN6TOnDPgKdXHLkNwzUinjLVbDxfy+zqPXBWerTz29JGm9 +DvCuTkSRhr1pVtiexPwvHLMK7rwLQp6HH1bOhT5GJT9jdo6LG01Po2d9vLupcHlWMe2 3PNQ== 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=B7tTgCNsWlBEoe4Yb/juuvNxXo9Zd9XsdoJybMCJwbU=; b=SRDKMY+CBRtRxn2H+fNkF73wmHT/u3HH3WK2Kafg4mNOJCoVMLZZI8I8t+7AH4W6q8 wnyCVAgIcOLRSHWbO6RqFyAhpWk2whAYkxZchZZ9qJ4/Qsq/RH0kfNqEMtdxlZx2hWNR IQA6QGoyzForHa36+TZUKQ2zuxVTEgJTrJubIfPML8GeG0kh5yZk24deW+v0ujcNN7hj aidngapFxImOXaukQXdMLJdgAf4jxMY+X7Wif4tCM3vKnWSH6XJ6gEdYuSFegLdCCCH3 UEWm8l1e1a8mV/Yt4uYpNqa2pGsTy5kgx8uA4UFbNdWFO+p8C8jI1I3VtQHHD7ObF2jP 5GVA== 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 z2-20020a50eb42000000b0047338d1bfabsi28117072edp.164.2023.01.04.08.46.16; Wed, 04 Jan 2023 08:46:16 -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 4707768BCAF; Wed, 4 Jan 2023 18:45:31 +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 CD52C68BCFA for ; Wed, 4 Jan 2023 18:45:24 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 303002405F9 for ; Wed, 4 Jan 2023 17:45:22 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id pWWwpvAdEIAI for ; Wed, 4 Jan 2023 17:45:20 +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 9A27F2405EC 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 B5AF53A035B 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:44 +0100 Message-Id: <20230104164246.6133-6-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 6/8] fftools/ffmpeg: reindent after previous commit 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: gSXUCJ2Yn6gM --- 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, From patchwork Wed Jan 4 16:42:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39868 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp8942203pzb; Wed, 4 Jan 2023 08:46:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXvx4H0/DZIHzgfdOMYHwk2p34nEeUqe0TV1uJT6m6vjOVWzJKY/dFhzh/AE9HegdUOam0NN X-Received: by 2002:aa7:c516:0:b0:485:48ed:b1f3 with SMTP id o22-20020aa7c516000000b0048548edb1f3mr28971905edq.26.1672850767013; Wed, 04 Jan 2023 08:46:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672850767; cv=none; d=google.com; s=arc-20160816; b=IrHbLMl/97yWLGzOBZlflY8y+GRfeWy7mzFwoTjWA0RG1Fs+9KLqQw4ofKpx+WdChC R2Ismp7Epw/y4luZBY3RRr7fgJlZWu5+GMnjMSuBv7F1rpb0B+Lwa0Aix55KWnhbhyDF zc+wycAVHdqYBWzAlPZHwMf+34i7RMyjgmcMgN+X2PzjF1aTtoCGkEN4aQg7GSvF9PE+ 03ydgEUWAXoAKH0uZPCth81YfjZYctMrGdDbjUrZm+YX4JtHAOmDYoT3Q9QsErWM11Qd Az/8LsWn+Bii3oWgOuFj3AsInccpe9a1CAy1gX2Wzq2wvQUqgThVq+cHqY5Cso7y2/UX ordg== 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=Y8tTvgBplSG41FuOZDuzikSTXvRMmcJLkX0bvZfqOHM=; b=P/sWV/dpQWCn2G2yy48dQn6bTU2Wpdu2JC9mkUY4j9SK+nnn8TGb2tjXHrHyH+bI/p wCuKfR+IFXb6FCR/3OEoh6gr3iYFdoss7OaxqcF+OvtjKeKPsaFJa8b0uDO1TfHN1D81 aehCwvdu9JDl7YlEKP35AkwcFFWBtD4N3dsNCRIwjZ5ST/n3EfUu2Iol0UNFAeDH6NyW UD7Ba+2R407YbzeMzuyeA7FPXC+Z4UNSAS//psiYRdmQZxwg3jbL6E0rwmkLVYqdEUC9 bgemubMkl62KBC3B5WREGFXKVB3lpjiPxnko58lCXbMVKOot8/LQd3gSnNel1EIThSwL 0XXQ== 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 y11-20020a056402440b00b0048ea26ce021si8231588eda.68.2023.01.04.08.46.06; Wed, 04 Jan 2023 08:46:06 -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 36EA968BD07; Wed, 4 Jan 2023 18:45:30 +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 1ACA568BCE0 for ; Wed, 4 Jan 2023 18:45:22 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 933D2240499 for ; Wed, 4 Jan 2023 17:45:21 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 6PVPvOuHP6Wp for ; Wed, 4 Jan 2023 17:45:21 +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 9BF8D2405F9 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 C0CA93A03D9 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:45 +0100 Message-Id: <20230104164246.6133-7-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 7/8] doc/ffmpeg: improve -r documentation 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: CJ5k3ih+AohA 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). 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