GNOME Bugzilla – Bug 765093
baseparse: Timestamp tracking has accumulating rounding errors when using frame rate
Last modified: 2018-11-03 12:34:24 UTC
Audio parsers often just use the frame rate based timestamp tracking, i.e. gst_base_parse_set_frame_rate(). The base class then simply stores fps_d/fps_n and uses this for the buffer durations. And then uses the buffer durations to interpolate the next buffer timestamps. So if upstream only provides timestamps every now and then, or only one in the very beginning, or none at all (filesrc ! mpegaudioparse ! ...), the rounding errors caused by the division will accumulate until the point when things start to fail.
Basically we should remember the frame rate and not the duration as a fraction, start counting from a anchor the number of frames and then calculate the current duration based on the number of frames, the frame rate and the anchor. The anchor should probably be based on the last known upstream PTS/DTS and be reset whenever upstream provides a new timestamp somehow. But also needs to take into account changing frame rates, and subclasses providing durations sometimes instead of nothing, and ...
Note that for MP3 with 44.1kHz, we increase timestamps by 0.9796 nanoseconds less per 1 second than we should. That's probably neglible, the 40ms alignment threshold in baseaudiosink (40ms) would happen after almost 463 days.
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/169.