[FFmpeg-trac] #11628(avformat:new): Ogg: Bad keyframe validation (was: Ogg: Broken file, keyframe not correctly marked)
FFmpeg
trac at avcodec.org
Mon Jul 28 11:36:38 EEST 2025
#11628: Ogg: Bad keyframe validation
------------------------------------+------------------------------------
Reporter: Bernat | Owner: (none)
Type: defect | Status: new
Priority: normal | Component: avformat
Version: git-master | Resolution:
Keywords: | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
------------------------------------+------------------------------------
Changes (by Bernat):
* summary: Ogg: Broken file, keyframe not correctly marked => Ogg: Bad
keyframe validation
* version: unspecified => git-master
Old description:
> FFmpeg show this message whenever an Ogg page having a granulepos
> corresponding to a keyframe contains a non-keyframe, besides the
> mandatory keyframe. And viceversa.
>
> It seems FFmpeg expects pages to contain only non-keyframes or only
> keyframes, depending on the granulepos of the page, but never a mix of
> both.
>
> Ogv files produced by FFmpeg are like that, but other Ogv files aren't.
> And I think the Ogg specification doesn't require it.
>
> The `encoder_example` program in the Theora package doesn't follow this
> practice and mixes both. It does some things wrong too, so I don't know
> whether we can trust it.
>
> I don't know if it's an exclusive requirement in FFmpeg or if it's indeed
> written somewhere in the documentation.
>
> If it's not really a hard requirement, the message could be changed to
> something that doesn't say "broken file" to not scare users.
>
> Thanks!
New description:
FFmpeg shows the error "Broken file, keyframe not correctly marked" on
valid files.
I think this is a bug in the function that validates keyframes,
`ogg_validate_keyframe`. This function will check every packet/frame
against the granulepos of the page, instead of the calculated granulepos
of the packet/frame.
This means that any page that mixes both keyframes and non-keyframes will
display the error, even though the frames are correctly marked.
Decoders should calculate their own granulepos for every packet/frame and
use the page granulepos as a reset mechanism for when the stream is
corrupted.
Ogv files produced by FFmpeg never seem to mix both types of frames in the
same page and don't trigger this error. The Theora example encoder
produces files that trigger the error. I think the Ogg specification
doesn't require frame types not to be mixed in the same page.
Thanks!
--
Comment:
I've updated the ticket after looking deeper into it. It looks definitely
like a bug.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/11628#comment:1>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list