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 744191 - encodebin: Need more buffers in output queue for better performance
encodebin: Need more buffers in output queue for better performance
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
1.4.1
Other Linux
: Normal enhancement
: 1.11.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-02-09 07:58 UTC by kevin
Modified: 2017-01-02 12:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Need more buffers in output queue for better performance (1.14 KB, patch)
2015-03-13 10:14 UTC, kevin
committed Details | Review

Description kevin 2015-02-09 07:58:42 UTC
Issue:

The camera application which based on camerabin performance is bad. The recorded file only has 16 fps. Our expect is 30 fps. Recorder can reach 29.9 fps after changed encodebin output queue buffer count to 50.

Root cause:

encodebin have two queue, one for video encoder input buffer, the other used for video encoder output buffer. The input buffer can buffer more data when video encoder performance is bad.

The output queue set max buffers to one. Our video encoder is based on hardware, the video encoder performance is ok for 1080p@30fps. Video encoder use video buffer pool with video source, the video buffer pool has limited max buffers, so the input buffer can't buffer too much video frame buffers.

The root cause of the issue seems the file sink will cost long time when the cached file sync to external storage.

Solution:

1. Change the output queue setting. Maybe same with input queue.
2. Add one queue between muxer and filesink. The queue should buffer many buffers to remove the storage effect.

What's you option. I can upload after we have decision.
Comment 1 kevin 2015-02-12 10:14:09 UTC
Communicate on IRC:

<slomo> kevin1_: why not just put another queue after encodebin?
<kevin1_> so, need fix it in camerabin?
<kevin1_> add one queue between encodebin and filesink?
<slomo> maybe... otoh the file system buffers probably should also take care of not causing such a problem
<kevin1_> output queue in encodebin only have one buffer. is it possible to block encode if muxer has audio/video interleave requirement?
<kevin1_> I test write file system on Linux and Android long ago. The write will consume 1.5 second sometime when 1080p recording. the output bitrate is 8Mbps.
<kevin1_> The write peak will occur every about 5 seconds.
<slomo> also sounds like a problem with some IO configuration if it can't keep up with a continuous write rate of 8Mbps but can still do that on average over 5 seconds
<kevin1_> The storage write speed is ok for 8Mbps. Most of write call is very quick. one write will block 1.5 second. I also test it on Ubuntu. it has same behave. But the test is years ago.
<kevin1_> Ubuntu should be default storage configuration.
<kevin1_> the worst case is about 1.5 second.
<slomo> kevin1_: yes that's what i mean with insufficient buffering at a lower layer :)
<kevin1_> storage will sync cache periodly. sync will consume more time if the sync interval too large.
<kevin1_> do we need handle it in gstreamer when recording?
Comment 2 kevin 2015-02-19 10:36:22 UTC
Do you need more evdence for the issue? I can provide more if you neet it.
Comment 3 kevin 2015-03-13 10:14:14 UTC
Created attachment 299298 [details] [review]
Need more buffers in output queue for better performance

Use the workaround in our platform.
Comment 4 Tim-Philipp Müller 2017-01-02 12:58:36 UTC
I have pushed your patch in slightly different form.

commit 01f467f6a466702900646298e1790bab2f134f38
Author: Song Bing <b06498@freescale.com>
Date:   Fri Mar 13 18:04:31 2015 +0800

    encodebin: allow more buffers in output queue for better performance
    
    https://bugzilla.gnome.org/show_bug.cgi?id=744191


You just unset the buffers + time limit, which by implication leaves the byte limit active. I think it's generally nicer to just set a time limit. I've picked 3 seconds for now. Hope that works for your use case as well.