From patchwork Tue Sep 24 07:09:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51783 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:ad12:0:b0:48e:c0f8:d0de with SMTP id w18csp170881vqy; Tue, 24 Sep 2024 00:11:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWFoe1v97h3uDBWi8WP55A5MhgXfhJHFCqcWB2SEmSMeOpRCY51GkwOQPn9TYKVhmpq5PCNxmrSwv8GoZ0Kscdl@gmail.com X-Google-Smtp-Source: AGHT+IGfjCvA08zkwoDmHoPW/bA+l9TIIubtL7UKv1lgyYZKUOfWvkjK9kDXcChx+eNH3WF5kHJ4 X-Received: by 2002:a17:907:e93:b0:a8d:2624:1a87 with SMTP id a640c23a62f3a-a93910ef671mr51042266b.14.1727161865432; Tue, 24 Sep 2024 00:11:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727161865; cv=none; d=google.com; s=arc-20240605; b=gFh80T11u+GRpHS2IAVqu3mS1KO8+mCHfB5erJ7/AQyhuzU/wr/5TDgmGanL2Xa+gO fYP6r7U6yD14fyhLz7PtLozP89jLOCqQ/RzAkhhtGzQRqiZDzhNKeZyhQcqyx4wspROj OHBtWTgYmeacRfUeCQ07vWTbzkgnti3Bls91MCrM0NwdtsfGMiT6dZJV0vqvjPzRdQ3a sw6qYVT6fioHksQ3Mpe2zeN6LnIOLkCjbXsbUC6pvm/8/v55UFxRVsTL1tw/U3H7gaiU gfBHHJNGqgrGUzSqlory6j3AQFAI7I704sBkr+d0mQzKxMXar3Gy/OtcV0xVdbZaFKws jGNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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:dkim-signature:delivered-to; bh=K6BTBtXG7FH9x0VVRtpA/68y38JutHmCG6g6Ddz7Yzo=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=K6/hFzr52QuoHq5nYN8E/ksAE+4w9rbiA/Mu7CyOwv305jT3mVhoET/ycOLDvI5vs1 mu/Rpapk/m077VLmiAX0m/GxH2R55J/bFdxVHO0L6rLoQUDxVjAEjbf5iLheD5MPE18/ UfPaeE7I8I593u0ti7Pfk0v4GSans6zRdLo6s3B3PBxrejaN7XngWsa1Nlu0pYWrMtfj P3d/vA/8I6mDvJisR6ngK7sZbq1qdxEPwtnqVdaFfM/tMaLFrS3gXLr7mirPvpgTRsYV 0eH2PwGpm1qSsrCYNlmegfIhWZ2IhPVnsmTVq8946PmDPzTH7q8mTUvKSMxcNOTwJzuj 9TXA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=TJp4W0Yu; 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 a640c23a62f3a-a93930ec21bsi58228066b.554.2024.09.24.00.11.04; Tue, 24 Sep 2024 00:11:05 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=TJp4W0Yu; 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 A94A168DB45; Tue, 24 Sep 2024 10:10:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AC12468DA4A for ; Tue, 24 Sep 2024 10:10:17 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=TJp4W0Yu; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 4F0134DE2 for ; Tue, 24 Sep 2024 09:10:17 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id kAKtNCzeF29t for ; Tue, 24 Sep 2024 09:10:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1727161815; bh=/3lsWZPOav4GPTc1WU3KjtdNmv/npDLm4zdQxCcphSU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=TJp4W0Yu8fJN/uFuhgRKse3YmexXZ6nZwI0eOulfP59ATTjW6aikOCdG4Nm/qmUr/ eQMHaFY8Dc8/X0Dxc/mOZV1SRJvphrRaFuK7SWtGxAJuUm4k/hCTYu1cVvjrU0IZah THMcxypzY5hDqgN95hOKhT/6bUJ5LWlGAyD7jjNNwlaVElWTdqK9D8w6klGTmKH86L ZwdYWENm59Jeb8pZxuukRoFXo5r/80YKYCj7uEDxL6n9w6Xa3fUn60a3T+SVQaibRA HhBTdRqaTmgffS4bUHaqBHXAIdVRMcORnPz6LcX1nUJQb4PdGMpFHMtRrr8U0qpzZ2 DpsqRGUQZZ1GA== 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 mail1.khirnov.net (Postfix) with ESMTPS id 6F12D4E09 for ; Tue, 24 Sep 2024 09:10:15 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 356703A17BA for ; Tue, 24 Sep 2024 09:10:10 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 24 Sep 2024 09:09:49 +0200 Message-ID: <20240924071000.11428-8-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240924071000.11428-1-anton@khirnov.net> References: <20240924071000.11428-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/13] fftools/ffmpeg_enc: don't write frame rate/SAR to AVStream directly 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: 5eBMy3TZyq9y Have the muxer code read them out of the encoder context in of_stream_init() instead. This is a step towards decoupling encoders from muxers. --- fftools/ffmpeg_enc.c | 3 +-- fftools/ffmpeg_mux.c | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 1be0a37353..4b3efb8db1 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -206,7 +206,6 @@ int enc_open(void *opaque, const AVFrame *frame) if (ost->type == AVMEDIA_TYPE_AUDIO || ost->type == AVMEDIA_TYPE_VIDEO) { enc_ctx->time_base = frame->time_base; enc_ctx->framerate = fd->frame_rate_filter; - ost->st->avg_frame_rate = fd->frame_rate_filter; } switch (enc_ctx->codec_type) { @@ -233,7 +232,7 @@ int enc_open(void *opaque, const AVFrame *frame) frame->height > 0); enc_ctx->width = frame->width; enc_ctx->height = frame->height; - enc_ctx->sample_aspect_ratio = ost->st->sample_aspect_ratio = + enc_ctx->sample_aspect_ratio = ost->frame_aspect_ratio.num ? // overridden by the -aspect cli option av_mul_q(ost->frame_aspect_ratio, (AVRational){ enc_ctx->height, enc_ctx->width }) : frame->sample_aspect_ratio; diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index ea0bbeed32..d38f1ec317 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -620,6 +620,9 @@ int of_stream_init(OutputFile *of, OutputStream *ost, if (ost->st->time_base.num <= 0 || ost->st->time_base.den <= 0) ost->st->time_base = av_add_q(enc_ctx->time_base, (AVRational){0, 1}); + ost->st->avg_frame_rate = enc_ctx->framerate; + ost->st->sample_aspect_ratio = enc_ctx->sample_aspect_ratio; + ret = avcodec_parameters_from_context(ms->par_in, enc_ctx); if (ret < 0) { av_log(ost, AV_LOG_FATAL,