After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 652158 - [baseparse] doesn't interpolate timestamps
[baseparse] doesn't interpolate timestamps
Status: RESOLVED NOTABUG
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other All
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2011-06-09 05:04 UTC by Matej Knopp
Modified: 2011-06-10 19:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch for timestamp interpolation (566 bytes, patch)
2011-06-09 05:04 UTC, Matej Knopp
none Details | Review
Correct patch (1.39 KB, patch)
2011-06-09 05:05 UTC, Matej Knopp
rejected Details | Review

Description Matej Knopp 2011-06-09 05:04:21 UTC
Created attachment 189524 [details] [review]
Patch for timestamp interpolation

The comment in code

    /* move along with upstream timestamp (if any),
     * but interpolate in between */

suggests that gstbaseparser interpolates the timestamps but it doesn't seem to be the case. I tried running lame encoded stream through mpegaudioparser in order to split it in frames before I feed it to muxer but the audio was all garbled because of invalid timestamps. 

Attaching a patch that does the interpolation.
Comment 1 Matej Knopp 2011-06-09 05:05:57 UTC
Created attachment 189525 [details] [review]
Correct patch

Correct patch, please ignore the previous one.
Comment 2 Mark Nauwelaerts 2011-06-09 08:04:58 UTC
baseparse does interpolate timestamps based on frame duration [*]

Other than some coding style issues and the fact that priv->frame_duration need not always be set (which is not considered here), the suggested interpolation is a somewhat hack-ish one that may work for some cases (e.g. note that fsize need not be constant), but not for all that baseparse has to cover.

In essence, any downstream element (be it baseparse based) sort-of has to trust upstream timestamps and can only go so far in fiddling with those.
As such, timestamps would basically have to be fixed upstream.

In this particular case, lame(mp3) likely has a hard time in doing that correctly in the first place since a.o.o encoder does not return whole frames (iirc).  Inserting a helper element before the parser that invalidates timestamps might/should help (as that then gives downstream parser a chance to come up with its own ones).

[*] that is, if an incoming buffer holds several frames, each outgoing frame will have different timestamps derived/interpolated by previous frame duration
Comment 3 Matej Knopp 2011-06-09 08:13:18 UTC
So the problem here, if I understand correctly is that lame encoder returns incomplete frames (for now ignoring that it also returns wrong timestamps, opened another bug for that)? I was under impression that I should be able to use mpegaudioparser to correct that, but now it looks like it doesn't cope with incomplete frames on the input "by design"?
Comment 4 Matej Knopp 2011-06-09 08:19:40 UTC
Also please note that even though there are incomplete frames in the input, the timestamps are correct. However after the data is processed by mpegaudioparse, the timestamps on output are wrong. So perhaps there should be mentioned at least somewhere what exactly the parser expects in the input to work.
Comment 5 Mark Nauwelaerts 2011-06-09 08:27:34 UTC
In as much as (I feel that) downstream can only 'correct' (rather than
complement/supplement) upstream that far, yes.  And it is a bit open as to how 'correct' a timestamp can be for a piece of a frame.

Also, the size-to-time == bitrate relation assumed by the calculation need not
be valid for all possible types of 'frame' and as such restrict what baseparse
can do [*]


[*] it might be argued that baseparse does actually estimate a bitrate and uses
this one for (approximate) position tracking etc fairly generally, so one might
then use this bitrate in stead to perform some interpolation on partial frame.
However, that would introduce even more 'approximation' into baseparse, and no
real assurance how well that works (in combination with possibly bogus
upstream), so such behaviour should probably be optional (controlled by some
property).  Only the interpolation performed currently (and described earlier)
can really be exact.
Comment 6 Matej Knopp 2011-06-09 08:35:44 UTC
Well, I've only tested it with MP3 frames where the size-to-time/bitrate assumptions kinda works, at least for CBR. Perhaps (if at all) this should be handled by mpegaudioparse rather than baseparser. On second thought maybe the real issue here is Lame output not being aligned to frames.
Comment 7 David Schleef 2011-06-10 19:23:19 UTC
Why does lame generate incomplete frames?  That seems like a good way to destroy timing information.  IMO, that's a bug all by itself.
Comment 8 Matej Knopp 2011-06-10 19:27:44 UTC
Well, the lame plugin doesn't attempt to generate complete frames, it just sends to output whatever the encoder gives it. 

I've submitted a report for lame encoder generating incorrect timestamps, but now I think that the problem is that the encoder should just output entire frames.

https://bugzilla.gnome.org/show_bug.cgi?id=652150