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 2A9AF4BF37 for ; Tue, 4 Feb 2025 15:14:18 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E005968B5B9; Tue, 4 Feb 2025 17:14:13 +0200 (EET) Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2F3A168A1CE for ; Tue, 4 Feb 2025 17:14:07 +0200 (EET) Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-2f9d9ee2ec2so162087a91.1 for ; Tue, 04 Feb 2025 07:14:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738682045; x=1739286845; darn=ffmpeg.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=UTYXaHJcLPpn9d9AlbjmtaarM7d4mXwt7Qq3lGHqwzM=; b=k0X0jtB6gmHMFg7uoaOxvwe+S1yIeetYu/BVQQH95C36JcAZjaOa1Iz74NX8LgmLmA +dSr4HsThqUavKQ8RduPMcQCZScoKTZ/7NxAv8kjuu7onFiwqqxk2pECCv7E1C/fPQb6 d2i8JAXgMpm+UxACHqlW7PreIT54d0doPfAooXU7zeWlm/1S2Krg8/PkgnB393oo3TvY 7O1+iW0fell44utiapXI6TufMaFjswYqbwuN2jAcLaeFG+dwhRr0TzF8a551ZC+sD8CD QebMr0TMN9XaUFekUk2KV2yWhLvxGTb12rvQUnfIQoajv2BFmC6GeqA7CNyDRLLpyi8s 0d9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738682045; x=1739286845; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=UTYXaHJcLPpn9d9AlbjmtaarM7d4mXwt7Qq3lGHqwzM=; b=LaoBsCl4KlvKvKFFEeUbS8tpuIpN7bt7Ad5UyEzPh+8jA/WHocwm/fn237AVjhi0e6 EMftbLYCgMKMpnq08FOKWHS/VfCAf0rhWcvaicKUgWXo8eJd8SFqMeJPer/2DT/Uc3iJ A/XcQV4y5NloJCHQvOk4an/v+LfuYhmOz32XAX768hlHFOePQYW9iSeBUlPNz8GIEUg8 037Vk7lGxrKa+ycvEhWPJp20Pdq58uihK0tq6Jn4Vwm0sGTR1++y6wydz/r/CUCjOfQ1 NRPoFyqmggVbgEZC1qVopcaJNLWP41KiwkyAfOFs/faADN7I5Pi+bIaI75utHfiFXG9C RkhQ== X-Gm-Message-State: AOJu0Ywew+ME+QrgJiSaFQbNtwrfT7z7938xGJSbnCJVb9XfqzYq2le3 myN1P+9ZHFHQk81BnABjgLjppunkLBdpl8En2GjnW8gNo+PKogTrvf8I1RyTnTABUCrSR+yaPyv dMtzH5kMVKNIs1kfvdiWDxooxV9htCSoOTRU= X-Gm-Gg: ASbGncsbh8HYDkk5XOlitjXBNyMiO5IzS+MbMbM28twlcvXqiRw5b33b5GrPHQEEvCN gX98LkhPs0eA8NKdYxXrDUCaWXHcmj+UcxWHdI1qhtet6GFKXeu1fsL51CYTSA+rh9XfM/BEJ X-Google-Smtp-Source: AGHT+IGF8TrHulK9UbKFQaNmIsIkn/QkoJriEuNpaY6VuCooKUZJYI36sBFJhG72FlNbYmkSB6FKgA657hk0Zj+DBqQ= X-Received: by 2002:a17:90b:5445:b0:2ee:aa28:79aa with SMTP id 98e67ed59e1d1-2f83abc3161mr35877080a91.6.1738682044885; Tue, 04 Feb 2025 07:14:04 -0800 (PST) MIME-Version: 1.0 From: Jack Lau Date: Tue, 4 Feb 2025 23:13:53 +0800 X-Gm-Features: AWEUYZndubmdyVPD0mFY6o0ERoPyF8Byf5pbUuNE3Vc8_NmwFKuBz58ZQ-z5-lo Message-ID: To: ffmpeg-devel@ffmpeg.org X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: Jack Lau --- 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".