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 30D294BFD2 for ; Wed, 5 Feb 2025 02:18:01 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 10CB768B5DB; Wed, 5 Feb 2025 04:17:57 +0200 (EET) Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B699568B36C for ; Wed, 5 Feb 2025 04:17:50 +0200 (EET) Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2f9d627b5fbso1505798a91.2 for ; Tue, 04 Feb 2025 18:17:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738721868; x=1739326668; darn=ffmpeg.org; h=content-transfer-encoding:content-language:to:subject:from :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=jNhb4ywkP0PTUwZkNkCau7nz2j3a9Iliyb2nmTYp9IY=; b=hDeQA1lk642ALUKQW8YyYwvckpdkeXpqVJkFZO0jMiaFJo83XQ2gUS/OeoMH0R3UhE Hsy0FG+S6hMeXN79vOV8gdeYsjTe1sQjXp8peIEozhnJqvLCnYG1j7hGTQHFUmurSSw6 2EN1Zf0PpsMxhsMFMXnujdZD6y0qIUbvTzK0x9+4PKKudBqN7q6UqRCX6FHDm/WVo7nu D6LbQ/dYOKr6jvq9TzQdeK8xzPApDiRq/1OwX4ZZ0uFHJpuVcU9las5E5SOiOwbg22Wt voZL/k39dHO8xVqCzT/Yz/PdsC27b5Zvl9mGNnXeO8WAZpOIf3fZaPtAENtbEOaGZ/0F 6iTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738721868; x=1739326668; h=content-transfer-encoding:content-language:to:subject:from :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=jNhb4ywkP0PTUwZkNkCau7nz2j3a9Iliyb2nmTYp9IY=; b=OkMW/ndxcK2QC7PGuHh/XnZqijc7Wfm8gifoyxs9M+gpZaRacV+iCn3Tjp5DGsR5Km hseIIWwVfMUI0Q1ZYewq9FsVqSKeTeZ6FyEpEbzxhzcZwoWLyZQTZDeSWFnxhNM718l2 xuWf8DSIqzeX61cEfqn+fXnInsaP9R2e2ElHjXkn5Io/PhNijPWzwM9i9bNkwE1xqmCE FYLNKSa7KsWlX4O4+4dsfxEeUMiOSXQkiGjpjJd8eqOz0xn7pGKr22yupfhGiukBcBla fH4/Nj9sHDIzGREp3ege5HeLcQnYCcATMwbQQzXhwGGVv1R7NcHNgnJcn1HvzH+oRIWF +FgQ== X-Gm-Message-State: AOJu0Yyaz2XGIF+G8SKoJsxKcFjTydhoybjbZm+Sa4tRW16qz/lzmYee V30hfBoZnTKkLl/EM8DTw6/wrJgdxYr72xxqZdZnCT7BCtJQS9KbJHpwjq/Ms3k= X-Gm-Gg: ASbGncuhhsb6NtKiUGnAHuKqnzy3DYrKbtEJpG6ZX/Swol76fLBQ1KJeKzifODW6AeE yR4lNNFeb+1AnrohR37PlB8wkFS1VnRo0uiYJAct6WdKJl+rnTGjfxyTxFw12qllE7UkJ6oM4+3 w3XHgd80Y0OxFdnLpmBdME2ofxBT69eKJZ9kutt+t7/tjOs4N54lQC0uvu5EhvzCJDV+j1y2hgg Qv/oktkfuRq4LLjn9yM9RS9hdQ0OQXAisUEl0CK51C/34d89CN2lupnH7La9OmFQfSNj9MiMNr/ 4l3VHznP2n3pVKxJO80gjo/BmPvfs6PIQmDE X-Google-Smtp-Source: AGHT+IFeDfOVpg0Tbxxa3K1+V6Gox18Q0hSaTKweTaUWEbr8sW6mTvgZ2wcP680ahoqYp21bt/5a4Q== X-Received: by 2002:a17:90b:3b88:b0:2ee:b8ac:73b0 with SMTP id 98e67ed59e1d1-2f9e0753dc6mr1742028a91.2.1738721867925; Tue, 04 Feb 2025 18:17:47 -0800 (PST) Received: from [192.168.31.126] ([123.11.80.244]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f9e1dbfc87sm266358a91.44.2025.02.04.18.17.47 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 04 Feb 2025 18:17:47 -0800 (PST) Message-ID: <931a0272-51d9-4bd7-a35f-b1f768fa154b@gmail.com> Date: Wed, 5 Feb 2025 10:17:45 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Jack Lau To: ffmpeg-devel@ffmpeg.org Content-Language: en-US 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" 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.48.1 _______________________________________________ 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".