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 ESMTP id D70A0405A8 for ; Tue, 22 Aug 2023 12:03:27 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8FE1768C45C; Tue, 22 Aug 2023 15:03:24 +0300 (EEST) Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7661E68BFB7 for ; Tue, 22 Aug 2023 15:03:17 +0300 (EEST) Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-4fe15bfb1adso6592929e87.0 for ; Tue, 22 Aug 2023 05:03:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692705796; x=1693310596; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=HZyZOoK4W12yp0eviHoA+WfvXG1oBeasnBc6cc7pX2I=; b=G3sm8bkgShKey7xshHStHThnKZlY6eve/z4ym6GqvslZPrRQNWqod0GLrj6STY3UgS wyL8+3w0GghKcPO/xGnb67Ky8Gi9E7AthgdBdDKgr9k16D67CR7KQM2ZfYmrjznbNPKq xNEokGyb926eU24RQxRGjrpmQ6YyAiMVH9og/w5LbUbltOo1qa4DAZjAcE5o7gWLfOnM 6slS0Su9snArP8aRkG6doy4b/4n9+m37980qZFt7cf36In8Iax6Kbyu+DhLFE6pLrEj9 IwVALEwq/tQFkyjx5IYtaot0KKB355IM5xgSLkGxC5gWE8F9vEeWNr/VjmEleY6jjFrN /unQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692705796; x=1693310596; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=HZyZOoK4W12yp0eviHoA+WfvXG1oBeasnBc6cc7pX2I=; b=ALVvklbhvhZtX+jtr6cj81KvUinLYqifkTUx9n6cgRfqjWvGoQXvDeDuMWrzlKvWEj L0sNEa2RMrsVOPMetTMDqA2IwH8MwyrwROTrfzpLz9A/LUCOiFlKtLoYUYImwRSP5jFr be71WHnqS8YrSEYd6Y1ro443anBgZnquNiNHDgpUobZ9oFHeSk6XqVdd6VWyO9MPlNWQ qd7xzSoAPlHyAMTekltD8HMKE6SmVl92R9caaiBASaMORMIYYMXVWX6SIsw8afIUDZnJ GgLc/vJKRvjd4mLS4WqTdfS2ZpbhfxfhvYynkBpYwDL3hP2E6EmmaIalVueXYtRDJR3L ySwA== X-Gm-Message-State: AOJu0YwoQDL570g8Z7NzYgGJtkEhQu3yJpKg4D2bqismsTM2CmuoeaBB 6+8P/FHITVLO5xNNa2i4nUXRYsRPb3xkKA== X-Google-Smtp-Source: AGHT+IGmxVCiY0NK9WqNL2cL5gN6DQwwhhHNuSXmI+eQoTtbCD3EsZZLpifwCa6UnSSTU152kzyXAg== X-Received: by 2002:a19:6d1b:0:b0:4f9:5a87:1028 with SMTP id i27-20020a196d1b000000b004f95a871028mr5263867lfc.30.1692705795495; Tue, 22 Aug 2023 05:03:15 -0700 (PDT) Received: from ulrikm-thinkpad.spotify.net (h-37-123-131-56.A498.priv.bahnhof.se. [37.123.131.56]) by smtp.gmail.com with ESMTPSA id v4-20020ac25584000000b004fbb1f7352csm2179381lfg.72.2023.08.22.05.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Aug 2023 05:03:15 -0700 (PDT) From: Ulrik Mikaelsson To: ffmpeg-devel@ffmpeg.org Date: Tue, 22 Aug 2023 14:03:04 +0200 Message-Id: <20230822120304.396910-1-ulrik.mikaelsson@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/mp3dec:Subtract known padding from duration 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 Cc: Ulrik Mikaelsson 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: When an Info-tag is present, marking initial and trailing samples as padding, those samples should not be included in the calculation of track duration. This solves a surprising user experience where converting a WAV->MP3->WAV, ffprobe will show the duration of the mp3 as slightly longer than both the input and the output. --- libavformat/mp3dec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index 05c13228bc..c8c3b298ab 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -350,7 +350,8 @@ static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base) avio_seek(s->pb, base + vbrtag_size, SEEK_SET); if (mp3->frames) - st->duration = av_rescale_q(mp3->frames, (AVRational){spf, c.sample_rate}, + st->duration = av_rescale_q((mp3->frames * spf) - mp3->start_pad - mp3->end_pad, + (AVRational){1, c.sample_rate}, st->time_base); if (mp3->header_filesize && mp3->frames && !mp3->is_cbr) st->codecpar->bit_rate = av_rescale(mp3->header_filesize, 8 * c.sample_rate, mp3->frames * (int64_t)spf); -- 2.39.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".