GNOME Bugzilla – Bug 595256
theoraenc: Buffer not time-contiguous with previous one
Last modified: 2010-09-28 14:03:43 UTC
The following produces warnings. GST_DEBUG=*theora*:4,identity:4 gst-launch videotestsrc ! theoraenc ! identity check-perfect=1 ! fakesink -v 2>&1 | grep -v data-cont | grep -v FakeSink | grep WARN It seems that in function theora_enc_get_ogg_packet_end_time() theora_granule_time (&enc->state, end_granule) * GST_SECOND has rounding issues. (for ex. the double 7.4000000 becomes 0.7399999 in clocktime) One way to hack the issue is to replace: GST_BUFFER_TIMESTAMP (buf) = timestamp; by GST_BUFFER_TIMESTAMP (buf) = running_time; Would that be acceptable??
Created attachment 143225 [details] [review] hack
For reference, this is the code under theora_granule_time() double th_granule_time(void *_encdec,ogg_int64_t _granpos){ oc_theora_state *state; state=(oc_theora_state *)_encdec; if(_granpos>=0){ return (th_granule_frame(_encdec, _granpos)+1)*( (double)state->info.fps_denominator/state->info.fps_numerator); } return -1; }
I don't think this would work when dealing with multiple segments. Better calculate the timestamp correctly, for example by doing the granulepos to time more accurately.
ok, another way is to remove parenthesis around ((double)state->info.fps_denominator/state->info.fps_numerator)) the following ex demonstrate it: #include <gst/gst.h> int main() { int i; double dbad, dgood; GstClockTime tbad, tgood; for (i = 0; i < 400; ++i) { dbad = i * ((double)1/30); dgood = i * (double)1/30; tbad = dbad * GST_SECOND; tgood = dgood * GST_SECOND; printf("%f %f\n", dbad, dgood); printf("bad %" GST_TIME_FORMAT "\n", GST_TIME_ARGS (tbad)); printf("good %" GST_TIME_FORMAT "\n", GST_TIME_ARGS (tgood)); if (tbad != tgood) return 1; } return 0; } However, I am not convinced that the bug comes from theora... but rather by usage of the timestamp in gstreamer.
Created attachment 143232 [details] small test Before I lost that file, I attach it here. It would be good to put that in the test suite, to avoid regressions, once we have a fix.
Things might become better if you use gst_util_uint64_scale_round() in theora_granule_time()
yep, but theora_granule_time() is from libtheora :)
I can't reproduce the bug with 0.10.30, closing my own bug. Thanks for taking the time to report this bug. However, you are using a version that is too old and not supported anymore. GNOME developers are no longer working on that version, so unfortunately there will not be any bug fixes for the version that you use. By upgrading to a newer version of GNOME you could receive bug fixes and new functionality. You may need to upgrade your Linux distribution to obtain a newer version of GNOME. Please feel free to reopen this bug if the problem still occurs with a newer version of GNOME.