libavcodec/opus/parser: Fix spurious 'Error parsing Opus packet header'

When PARSER_FLAG_COMPLETE_FRAMES is set, opus_parse() calls
set_frame_duration even on flush (buf_size==0), which triggers
a spurious "Error parsing Opus packet header" at EOF.

Match streaming-path behavior by skipping duration parsing on empty buffers.
Fixes #20954
This commit is contained in:
mux47
2025-11-18 16:43:49 +00:00
committed by James Almer
parent cac5018eb9
commit 618fc15e65

View File

@@ -189,7 +189,7 @@ static int opus_parse(AVCodecParserContext *ctx, AVCodecContext *avctx,
if (ctx->flags & PARSER_FLAG_COMPLETE_FRAMES) {
next = buf_size;
if (set_frame_duration(ctx, avctx, buf, buf_size) < 0)
if (buf_size && set_frame_duration(ctx, avctx, buf, buf_size) < 0)
goto fail;
} else {
next = opus_find_frame_end(ctx, avctx, buf, buf_size, &header_len);