PR #23016 opened by toots URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23016 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23016.patch
>From 97b938d81cdbfc3362693a74f63a072e88b44279 Mon Sep 17 00:00:00 2001 From: Romain Beauxis <[email protected]> Date: Mon, 4 May 2026 20:43:24 -0500 Subject: [PATCH] libavformat/oggparsevorbis.c: add initial offset to account for decoder priming. --- libavformat/oggparsevorbis.c | 9 ++++++++- tests/ref/fate/ogg-vorbis-chained-meta.txt | 22 +++++++++++----------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c index ed81a431f6..a7e0b1c58f 100644 --- a/libavformat/oggparsevorbis.c +++ b/libavformat/oggparsevorbis.c @@ -455,6 +455,7 @@ static int vorbis_packet(AVFormatContext *s, int idx) int duration, flags = 0; int skip_packet = 0; int ret, new_extradata_size; + int first_packet = !os->lastpts || os->lastpts == AV_NOPTS_VALUE; PutByteContext pb; if (!priv->vp) @@ -464,7 +465,7 @@ 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) { + if (first_packet && !(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; @@ -563,6 +564,12 @@ static int vorbis_packet(AVFormatContext *s, int idx) } os->pduration = duration; + if (first_packet) { + if (os->lastpts != AV_NOPTS_VALUE) + os->lastpts -= duration; + if (os->lastdts != AV_NOPTS_VALUE) + os->lastdts -= duration; + } } /* final packet handling diff --git a/tests/ref/fate/ogg-vorbis-chained-meta.txt b/tests/ref/fate/ogg-vorbis-chained-meta.txt index 5ec756663d..6584e23692 100644 --- a/tests/ref/fate/ogg-vorbis-chained-meta.txt +++ b/tests/ref/fate/ogg-vorbis-chained-meta.txt @@ -1,14 +1,14 @@ Stream ID: 0, codec name: vorbis, metadata: encoder=Lavc61.19.100 libvorbis:title=First Stream -Stream ID: 0, packet PTS: 0, packet DTS: 0 +Stream ID: 0, packet PTS: -128, packet DTS: -128 Stream ID: 0, new metadata: encoder=Lavc61.19.100 libvorbis:title=First Stream -Stream ID: 0, packet PTS: 128, packet DTS: 128 -Stream ID: 0, frame PTS: 128, metadata: N/A -Stream ID: 0, packet PTS: 704, packet DTS: 704 -Stream ID: 0, frame PTS: 704, metadata: N/A -Stream ID: 0, packet PTS: 1323, packet DTS: 1323 -Stream ID: 0, new metadata: encoder=Lavc61.19.100 libvorbis:title=Second Stream -Stream ID: 0, frame PTS: 1323, metadata: encoder=Lavc61.19.100 libvorbis:title=Second Stream +Stream ID: 0, packet PTS: 0, packet DTS: 0 +Stream ID: 0, frame PTS: 0, metadata: N/A +Stream ID: 0, packet PTS: 576, packet DTS: 576 +Stream ID: 0, frame PTS: 576, metadata: N/A Stream ID: 0, packet PTS: 1451, packet DTS: 1451 -Stream ID: 0, frame PTS: 1451, metadata: N/A -Stream ID: 0, packet PTS: 2027, packet DTS: 2027 -Stream ID: 0, frame PTS: 2027, metadata: N/A +Stream ID: 0, new metadata: encoder=Lavc61.19.100 libvorbis:title=Second Stream +Stream ID: 0, frame PTS: 1451, metadata: encoder=Lavc61.19.100 libvorbis:title=Second Stream +Stream ID: 0, packet PTS: 1579, packet DTS: 1579 +Stream ID: 0, frame PTS: 1579, metadata: N/A +Stream ID: 0, packet PTS: 2155, packet DTS: 2155 +Stream ID: 0, frame PTS: 2155, metadata: N/A -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
