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 746032 - audiomixer: doesn't handle buffers with repeating pts properly (broken discont detection)
audiomixer: doesn't handle buffers with repeating pts properly (broken discon...
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal normal
: 1.5.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-03-11 13:50 UTC by Nirbheek Chauhan
Modified: 2015-03-12 17:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Comparison of the output audio stream with and without audiomixer (114.78 KB, image/png)
2015-03-11 13:50 UTC, Nirbheek Chauhan
Details
Sample rtsp audio stream which yields duplicate timestamps with rtpjitterbuffer (89.46 KB, application/octet-stream)
2015-03-11 13:52 UTC, Nirbheek Chauhan
Details

Description Nirbheek Chauhan 2015-03-11 13:50:08 UTC
Created attachment 299097 [details]
Comparison of the output audio stream with and without audiomixer

If one sends a stream of buffers with duplicate pts to audiomixer, it happily takes those as sequential buffers and increments the pts on the output buffers. This is not how audio sinks handle buffers with duplicate pts, and causes audio-video to go out of sync.

Tim is investigating this; pasting his findings below:

----

gst-launch-1.0 filesrc location=output-gdp-audio.bin ! gdpdepay !
rtpjitterbuffer ! rtpmp4adepay ! decodebin ! audiomixer ! audiorate !
wavenc ! filesink location=with.wav

gst-launch-1.0 filesrc location=output-gdp-audio.bin ! gdpdepay !
rtpjitterbuffer ! rtpmp4adepay ! decodebin ! audiorate ! wavenc !
filesink location=without.wav

(see attachment for how the two look like in audacity)

Basically the code that checks for discontinuities is an echo chamber, it doesn't track divergence from actual position, but just compares each buffer with the next.

And then after mixing a buffer it does

   pad->next_offset = buffer_end_offset;

so if you send as input:

 0-1  1-2  1-2  1-2  2-3

then it will happily increase the audiomixer output offset every time, and next_offset will be reset on the second/third buffer (so here we lost sync to the output offset and are now systematically behind), and we'll never exceed any discont thresholds.
Comment 1 Nirbheek Chauhan 2015-03-11 13:52:04 UTC
Created attachment 299098 [details]
Sample rtsp audio stream which yields duplicate timestamps with rtpjitterbuffer

Usage:

gst-launch-1.0 filesrc location=output-gdp-audio.bin ! gdpdepay !
rtpjitterbuffer ! rtpmp4adepay ! decodebin ! ...
Comment 2 Sebastian Dröge (slomo) 2015-03-11 13:53:30 UTC
(In reply to Nirbheek Chauhan from comment #0)
> This is not how audio sinks handle buffers with duplicate
> pts, and causes audio-video to go out of sync.

Actually the code in audiomixer should be the same as in the audio sinks.
Comment 3 Sebastian Dröge (slomo) 2015-03-12 17:12:42 UTC
commit 472069a699e48b50bd7e5ecb710f4b496ade6205
Author: Sebastian Dröge <sebastian@centricular.com>
Date:   Thu Mar 12 17:11:31 2015 +0000

    audiomixer: Fix discont detection and buffer alignment code
    
    Actually accumulate the sample counter to check the accumulated error
    between actual timestamps and expected ones instead of just resetting
    the error back to 0 with every new buffer.
    
    Also don't reset discont_time whenever we don't resync. The whole point of
    discont_time is to remember when we first detected a discont until we actually
    act on it a bit later if the discont stayed around for discont_wait time.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=746032