#11454 closed defect (fixed)
Ogg/Theora: Bad granulepos when GOP higher than 64
| Reported by: | Bernat | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | avcodec |
| Version: | git-master | Keywords: | libtheoraenc |
| Cc: | Bernat, MasterQuestionable | Blocked By: | |
| Blocking: | Reproduced by developer: | yes | |
| Analyzed by developer: | yes |
Description (last modified by )
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.
Change History (9)
comment:1 by , 19 months ago
| Description: | modified (diff) |
|---|
comment:2 by , 19 months ago
| Description: | modified (diff) |
|---|
comment:3 by , 19 months ago
| Cc: | added |
|---|---|
| Component: | undetermined → avcodec |
| Keywords: | theora added |
comment:4 by , 19 months ago
No impact on playback but it has an impact on seeking. Granulepos is supposed to let you know how many frames back the previous key-frame is without decoding the video stream.
comment:5 by , 19 months ago
| Analyzed by developer: | set |
|---|---|
| Component: | avcodec → avformat |
| Keywords: | oggparsetheora added; theora removed |
͏ Is it alike the native "speex" decoder problems?
͏ https://trac.ffmpeg.org/ticket/11078#comment:12
͏ (using "-c:v libtheora" before "-i" may workaround?)
[ ^
͏ Probably not, as "libtheora" decoding support seems not implemented:
͏ https://github.com/search?type=code&q=repo:FFmpeg/FFmpeg+path:/^libav(?:codec|format)%5C/.*theora/
͏ .
͏ Yet found only:
͏ ͏"libavcodec/libtheoraenc.c"
͏ ͏"libavformat/oggparsetheora.c" ]
comment:6 by , 19 months ago
| Component: | avformat → avcodec |
|---|---|
| Reproduced by developer: | set |
| Status: | new → open |
Probably not, as "libtheora" decoding support seems not implemented:
The theora decoder is in vp3.c
Patch for this issue sent to the mailing list.
comment:7 by , 18 months ago
I've tried the patch and it seems to work well. The keyframes are where the granulepos say they should be. Thank you!
comment:8 by , 18 months ago
| Resolution: | → fixed |
|---|---|
| Status: | open → closed |
Fixed in 22aa71d4da37a4ad2b0d28deeace64b57aa2ef50.
comment:9 by , 18 months ago
| Keywords: | libtheoraenc added; oggparsetheora removed |
|---|
͏ Per the description looks like encoder problem:
͏ https://github.com/FFmpeg/FFmpeg/commit/22aa71d4da37a4ad2b0d28deeace64b57aa2ef50
͏ Theora decoder is in ͏"vp3.c":
͏ Rough search gave no hint what VP3 is... (too obscure)
͏ Is ͏"oggparsetheora.c" specifically only for extracting the Theora stream in Ogg?



͏ Briefly, it's only some decoded frame metadata wrong:
͏ But no impact on actual playback?