granulepos of vorbis stream is wrong when using --endtime switch
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ffmpeg2theora |
New
|
Undecided
|
Unassigned |
Bug Description
When using the "--endtime" switch to only encode data up to a cetain time value the ganulepos of the last page in created vorbis streams is exactly this time value. The problem is that there are actually more samples in the page than the granulepos says.
This is a problem because usually the starting sample of a page is calculated by taking the granulepos as the number of samples that can be decoded including this page and subtracting the decodable samples of all packtes in this page. At least this is the way liboggz does it.
It seems to me that when using the "--endtime" switch ffmpeg2theora adds sound packets to the stream until more than endtime samples have been written. But instead of the number of samples written it uses the value of "--endtime" as granulepos for the last page.
IMHO the granulepos of the last page should exactly match the number of samples of the whole stream.
To reproduce this:
ffmpeg2theora --endtime=5 synctest.mp4 -o "synctest.ogm"
The granulepos of the last page in a vorbis stream is 220500 for 44100 Hz stereo. The page before that has 215744 as granulepos. So the last page should contain 220500-215744=4756 samples. But there are actually 364 samples more in the last page.
The testvideo is attached.
tags: | added: vorbis |
tags: | added: granulepos |