[FFmpeg-trac] #11454(undetermined:new): Ogg/Theora: Bad granulepos when GOP higher than 64
FFmpeg
trac at avcodec.org
Wed Feb 5 17:24:27 EET 2025
#11454: Ogg/Theora: Bad granulepos when GOP higher than 64
-------------------------------------+-------------------------------------
Reporter: Bernat | Owner: (none)
Type: defect | Status: new
Priority: normal | Component:
| undetermined
Version: git-master | Resolution:
Keywords: | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Description changed by Bernat:
Old description:
> When encoding Theora video streams in an Ogg container with GOP size
> higher than 64, granulepos is wrong. The encoding is done with the right
> GOP size but the granulepos reported when decoding is wrong.
>
> Here's an example from a file encoded with the following command:
>
> {{{
> ffmpeg -i input.mp4 -c:v libtheora -c:a libvorbis -g:v 300 output.ogv
> }}}
>
> The output plays fine but when analyzing the frames we can find this:
>
> frame 64:
> granulepos: 575
> key-frame: 1
> offset: 63
> Theora API function th_packet_iskeyframe() returns false.
> frame 65:
> granulepos: 33280
> key-frame: 65
> offset: 0
> Theora API function th_packet_iskeyframe() returns false.
>
> So in both cases the decoder thinks these aren't key-frames and it should
> be right.
>
> But the granulepos of the second frame is constructed as if it was a key-
> frame. It should be like this instead:
>
> frame 65:
> granulepos: 576
> key-frame: 1
> offset: 64
>
> It looks like the encoder knows the GOP size is 300 but the code writing
> the granulepos thinks that the GOP size is 64.
>
> Anyway I could help please ask me.
>
> Thanks for your time.
> Cheers.
New description:
When encoding Theora video streams in an Ogg container with GOP size
higher than 64, granulepos is wrong. The encoding is done with the right
GOP size but the granulepos reported when decoding is wrong.
Here's an example from a file encoded with the following command:
{{{
ffmpeg -i input.mp4 -c:v libtheora -c:a libvorbis -g:v 300 output.ogv
}}}
The output plays fine but when analyzing the frames we can find this:
frame 64:
granulepos: 575
key-frame: 1
offset: 63
Theora API function th_packet_iskeyframe() returns false.
frame 65:
granulepos: 33280
key-frame: 65
offset: 0
Theora API function th_packet_iskeyframe() returns false.
So in both cases the decoder thinks these aren't key-frames and it should
be right. But the granulepos of the second frame is constructed as if it
was a key-frame.
It should be like this instead:
frame 65:
granulepos: 576
key-frame: 1
offset: 64
It looks like the encoder knows the GOP size is 300 but the code writing
the granulepos thinks that the GOP size is 64.
If there's any way I can help, please ask me.
Thanks for your time.
Cheers.
--
--
Ticket URL: <https://trac.ffmpeg.org/ticket/11454#comment:2>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list