From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id E9B074BF3E for ; Tue, 4 Feb 2025 15:35:31 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2136268B5CC; Tue, 4 Feb 2025 17:35:28 +0200 (EET) Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 967D568A966 for ; Tue, 4 Feb 2025 17:35:21 +0200 (EET) Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2f9c3124f31so1227171a91.0 for ; Tue, 04 Feb 2025 07:35:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738683320; x=1739288120; darn=ffmpeg.org; h=to:date:message-id:subject:mime-version:content-transfer-encoding :from:from:to:cc:subject:date:message-id:reply-to; bh=+jKixhTF6weLysZPkr0d6IfCs4n88zBItp/lBERwIwA=; b=BIIuByVZxzadLwEqGWMJfIDjk1vghrIuEASgKE8nCK4DStmImgPbG6N034bsy0NXd0 ZJRUphmiJu+deCUSqm9jrqlBJeTsq6ClW6uSFvVDnQaFYx1vS3yit5SVyjWqjF2JJnid Mf9Yi+YCEdMRQBX5q3F6nqn4/ImEiTsF4q7lMAAY9mmBVtnLpNHuK4aZdemMGkNqyxtG 28PT+vWu4XDt42lmNGhrYGggNYOew031+Q4GGhLzDoF+Ezpu+L3r5k31yoOFyVedj1z/ n/MlYjKifsWhbLlmEZI2Yacqdhi5UJhNgyg5qTON/NjEtrPXAIc8DB8bYCuqtLPIDtks iAnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738683320; x=1739288120; h=to:date:message-id:subject:mime-version:content-transfer-encoding :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+jKixhTF6weLysZPkr0d6IfCs4n88zBItp/lBERwIwA=; b=a80uIFTeQhlOXgVyyQ9+HXxn/Eux2Z4EMRtF2RQSrbCqL5ZKWftWmMnkSgecjo+ssH MBsWMgisSqaWOyOcg5G81fsuGEH274MnRHE8FtSjCAnjEzoDesqRbHrP60p37ibYzLRC 7qVRqEgnQoCq+q2H3s3dGNuweoj53zx07tY5IEVkXmkSIPEp7wa9+XG6fLCl8VNWKiop Ft20Nx+/PuR+hTqMuE2cXbbpyk3lb/ZMVRNOdrq8t4bfnnSr+/2cTXS6J93wFHsbpBIz rQwGBoQviZR8ZYPys9jTczKoKD4fKZkXVY2IuzQvo09goZ1iNWBYhFwxmnPYPf62EUMx MO2A== X-Gm-Message-State: AOJu0YzRVIVWDEyPhI6i/ue3YQK60hqvJ3ScEdII/ulNKbauSJPXC8ow tqh7TQu+B9vSGIXG3YiEZct8SOn316sm3bgSRjWOAZawIBAEaHzDu0VTD8mY X-Gm-Gg: ASbGncsimhiXyS5FI26p7MMYucfD90Ju7QthyydTWrmaGCH5X0IyqUnNStWd3CNtwQ1 ctQEu6ZRdsgPksuVPM2v4nWf0HRa8Gkk/sMwo7HEOwC7fHniPmcuXPwzUPCjCS9PUYizoY3iF4g 85srG5lkjeCc5HqgdyzdHTI9mrZnzFRj+LAviloLtFOddXiliwn7Pl8nSTcqm5HEoRVLs65VrFa VPiclHrhgmfKj7PAwIyLV72wJgbXaqFC2nPGzlTDK7Oz8GVO2bh9Nn3M1YnGPtZhtva8EgXknZ3 BP/sleC/y61D7PwvJ32RX99q7Q== X-Google-Smtp-Source: AGHT+IGfxt22JV2PyREwHlom37qT6jHkAiwCUbZn//4+UhR6W/m/dTcOJYxmo0iaw7sKvXYI4BVJiA== X-Received: by 2002:a17:90b:524a:b0:2ee:90a1:5d42 with SMTP id 98e67ed59e1d1-2f83aa82299mr47921630a91.0.1738683319381; Tue, 04 Feb 2025 07:35:19 -0800 (PST) Received: from smtpclient.apple ([62.192.175.76]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f83bf93e97sm14990458a91.31.2025.02.04.07.35.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Feb 2025 07:35:18 -0800 (PST) From: Jack Lau Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51.11.1\)) Message-Id: Date: Tue, 4 Feb 2025 23:35:03 +0800 To: ffmpeg-devel@ffmpeg.org X-Mailer: Apple Mail (2.3776.700.51.11.1) Subject: [FFmpeg-devel] [PATCH] examples/transcoding: Fix time_base handling 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: The `dec_ctx->time_base` was incorrectly default set to 0/60, while `enc_ctx->time_base` was derived from `dec_ctx->framerate`. This mismatch could cause incorrect video duration in the output. This patch aligns `enc_ctx->time_base` with `dec_ctx->time_base` to prevent rescaling issues and ensure correct video duration. Signed-off-by: JackLau1222 <2366536135@qq.com> --- doc/examples/transcoding.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/examples/transcoding.c b/doc/examples/transcoding.c index 013f89fc7d..847bdb7e1a 100644 --- a/doc/examples/transcoding.c +++ b/doc/examples/transcoding.c @@ -172,7 +172,7 @@ static int open_output_file(const char *filename) else enc_ctx->pix_fmt = dec_ctx->pix_fmt; /* video time_base can be set to whatever is handy and supported by encoder */ - enc_ctx->time_base = av_inv_q(dec_ctx->framerate); + enc_ctx->time_base = dec_ctx->time_base; } else { enc_ctx->sample_rate = dec_ctx->sample_rate; ret = av_channel_layout_copy(&enc_ctx->ch_layout, &dec_ctx->ch_layout); @@ -180,7 +180,7 @@ static int open_output_file(const char *filename) return ret; /* take first format from list of supported formats */ enc_ctx->sample_fmt = encoder->sample_fmts[0]; - enc_ctx->time_base = (AVRational){1, enc_ctx->sample_rate}; + enc_ctx->time_base = dec_ctx->time_base; } if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) -- 2.45.2 _______________________________________________ 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".