Message ID | 20220421032251.9866-1-gsun@roblox.com |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel] avformat/oggparsevorbis: Ignore duration of the first packet | expand |
Context | Check | Description |
---|---|---|
yinshiyou/make_loongarch64 | success | Make finished |
yinshiyou/make_fate_loongarch64 | success | Make fate finished |
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
andriy/make_aarch64_jetson | success | Make finished |
andriy/make_fate_aarch64_jetson | success | Make fate finished |
andriy/make_armv7_RPi4 | success | Make finished |
andriy/make_fate_armv7_RPi4 | success | Make fate finished |
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
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
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(+)