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 5982142F24 for ; Tue, 17 May 2022 00:05:46 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3F1BE68B425; Tue, 17 May 2022 03:05:44 +0300 (EEST) Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0754A68A8B4 for ; Tue, 17 May 2022 03:05:38 +0300 (EEST) Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-2ff155c239bso26026527b3.2 for ; Mon, 16 May 2022 17:05:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=skfqPz3RBI28yplqPz4oY9vjnMnzn9YOvB9DEhTHNrg=; b=Z9GxSvqbWH0Ebx7s2GmPVIwEriJxG2JnUhU1R3ub9VGH0v7PhFdmqshowlbjxVFSn5 xFNyNrC3/Hr6DX6QvORvilva1kf9aAWAzYngzpSC9tHOqEkoKqdA+pVr0w4KmxF2mLAA IJJRn6iXktiKTkbyudSwmjX5ihGpTF3lkdF3RzSGuQdbujzM9gmZFUbqGOhHSWdoW/Iq 2LyC/4kDztrXM1ABvhT622PNIo6DH8J7CRHUrYz1WYkzGzck7YgxNW4VX5tA2AQNEDtW xryTVckAogxnOSiDTocHqpo9gLvSxDVLlcYOwV2b3mRCNK8gTlKpkAyuKquy6dkUckeT 5IgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=skfqPz3RBI28yplqPz4oY9vjnMnzn9YOvB9DEhTHNrg=; b=vVoE/yKQ8Ua3/Vf2U32jw5yeJ8C8cWWLYdPGQtWiU2PzpOlHHJkYWlnmbtWw7ULoek 7kCtS7Ua51Zfmk+Rt54c0ei0CaOevPVRDz+cB87OId/lmoSZ34DZnllgNk0m9WxQJC+7 7iQMsG1MX+zMRkkeMHdXAP90eWQttetB9G6gkZ3JiOqXbfpuxzYEGgo6fEIGxU7BxPPM PNfrxAp5/IUqOw1o3QomXFCZ5SNXzo8xrwBr2WrWp9xsOYRYvL03At2k0TBJ30WORHrp ZY4Fgua2orqOQ93TLVU8aY5i97K1c9l5OA0CU+FdYC8eYkg/W7d4AXYGYmzCYXhjFh7N +PPg== X-Gm-Message-State: AOAM5324Uwd5dIZZxNtRv4WPb90grFcv0rkjx1AK5+h8qy3umJIwppY/ ibqCTj+stJHbTTBP6JP/xw5liWSAhfxORB3rmJxNTyNvsqU= X-Google-Smtp-Source: ABdhPJzASMvipO+LF33aDdyCseAnC+aX2EvaALVn+pmeZ8dpfb0X2G/l2nXXwjD41s6Ivkip6Pi7Bxv2VqDfuxmYeq0= X-Received: by 2002:a81:9188:0:b0:2fe:d01a:6b09 with SMTP id i130-20020a819188000000b002fed01a6b09mr13982678ywg.243.1652745935424; Mon, 16 May 2022 17:05:35 -0700 (PDT) MIME-Version: 1.0 References: <20220505230458.1024-1-gsun@roblox.com> In-Reply-To: From: Guangyu Sun Date: Mon, 16 May 2022 17:05:24 -0700 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [FFmpeg-devel] [PATCH] avformat/oggparsevorbis: Fix oggvorbis duration parsing for small files 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: On Mon, May 9, 2022 at 11:19 AM Guangyu Sun wrote: > On Thu, May 5, 2022 at 4:05 PM Guangyu Sun wrote: > >> The decoded Data is not returned from the first frame; it must be used >> to 'prime' the decode engine. The duration of the first packet should >> be ignored also by the container, to make sure the total duration is >> trimmed correctly. >> >> If the file has multiple pages for the data packets. The duration of the >> last packet can be correctly adjusted without being affected by the first >> packet. But if the first packet and the last packet are located in the >> same page, the duration of the last packet will have an unwanted offset. >> >> This commit fixes https://trac.ffmpeg.org/ticket/6367. >> >> dd if=/dev/zero of=./silence.raw count=1 bs=500 >> oggenc --raw silence.raw --output=silence.ogg >> oggdec --raw --output silence.oggdec.raw silence.ogg >> ffmpeg -codec:a libvorbis -i silence.ogg -f s16le -codec:a pcm_s16le >> silence.libvorbis.ffmpeg.raw >> ffmpeg -i silence.ogg -f s16le -codec:a pcm_s16le >> silence.native.ffmpeg.raw >> ls -l *.raw >> >> Signed-off-by: Guangyu Sun >> --- >> libavformat/oggparsevorbis.c | 11 ++++++++++- >> 1 file changed, 10 insertions(+), 1 deletion(-) >> >> diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c >> index 289900f7cf..9a486c9fe8 100644 >> --- a/libavformat/oggparsevorbis.c >> +++ b/libavformat/oggparsevorbis.c >> @@ -412,6 +412,7 @@ static int vorbis_packet(AVFormatContext *s, int idx) >> struct ogg_stream *os = ogg->streams + idx; >> struct oggvorbis_private *priv = os->private; >> int duration, flags = 0; >> + int first_page; >> >> if (!priv->vp) >> return AVERROR_INVALIDDATA; >> @@ -420,7 +421,8 @@ static int vorbis_packet(AVFormatContext *s, int idx) >> * here we parse the duration of each packet in the first page and >> compare >> * the total duration to the page granule to find the encoder delay >> and >> * set the first timestamp */ >> - if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && !(os->flags & >> OGG_FLAG_EOS) && (int64_t)os->granule>=0) { >> + first_page = !os->lastpts || os->lastpts == AV_NOPTS_VALUE; >> + if (first_page && !(os->flags & OGG_FLAG_EOS) && >> (int64_t)os->granule>=0) { >> int seg, d; >> uint8_t *last_pkt = os->buf + os->pstart; >> uint8_t *next_pkt = last_pkt; >> @@ -479,6 +481,13 @@ static int vorbis_packet(AVFormatContext *s, int idx) >> flags = 0; >> } >> os->pduration = duration; >> + /* Data is not returned from the first frame; it must be used to >> 'prime' >> + * the decode engine. The duration of the first packet should be >> ignored >> + * also by the container, to make sure the total duration is >> trimmed >> + * correctly. >> + */ >> + if (first_page && os->segp == 1) >> + os->pduration = 0; >> } >> >> /* final packet handling >> -- >> 2.30.1 >> >> > Ping. > Ping again. This patch fixes an oggvorbis transcode issue. https://devforum.roblox.com/t/recent-changes-to-uploaded-audio-compressionprocessing-causing-timing-drift/1735440/10 _______________________________________________ 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".