Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Guangyu Sun <sunguangyucn@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] avformat/oggparsevorbis: Ignore duration of the first packet
Date: Mon, 2 May 2022 09:52:01 -0700
Message-ID: <CALZ-8ZN2fMBMVwv7WGN7v7xcytRQbQcGSsCNd82hRZdPzYgWuQ@mail.gmail.com> (raw)
In-Reply-To: <20220421032251.9866-1-gsun@roblox.com>

On Wed, Apr 20, 2022 at 8:22 PM Guangyu Sun <sunguangyucn@gmail.com> 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.
>
> This commit fixes #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 <gsun@roblox.com>
> ---
>  libavformat/oggparsevorbis.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
> index 289900f7cf..1f922b3c7e 100644
> --- a/libavformat/oggparsevorbis.c
> +++ b/libavformat/oggparsevorbis.c
> @@ -479,6 +479,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 ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && os->segp
> == 1)
> +            os->pduration = 0;
>      }
>
>      /* final packet handling
> --
> 2.30.1
>
>
Ping. This patch fixes audio duration mis-match after transcoding a small
ogg/vorbis file.

Thanks,
Guangyu
_______________________________________________
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".

      reply	other threads:[~2022-05-02 16:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-21  3:22 Guangyu Sun
2022-05-02 16:52 ` Guangyu Sun [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALZ-8ZN2fMBMVwv7WGN7v7xcytRQbQcGSsCNd82hRZdPzYgWuQ@mail.gmail.com \
    --to=sunguangyucn@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git