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 595614 - theora/enc/dec playback drops buffers/freezes intermittently
theora/enc/dec playback drops buffers/freezes intermittently
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on: 595825
Blocks:
 
 
Reported: 2009-09-18 17:53 UTC by Tristan Matthews
Modified: 2018-11-03 11:15 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Tristan Matthews 2009-09-18 17:53:10 UTC
Running either of these pipelines leads to choppy playback and frames freezing:

gst-launch -v v4l2src ! video/x-raw-yuv, width=640, height=480, framerate=30000/1001 ! theoraenc ! theoradec ! queue max-size-buffers=3 ! xvimagesink

This one only freezes at the beginning of playback:

gst-launch -v videotestsrc is-live=true ! video/x-raw-yuv, width=640, height=480, framerate=30000/1001 ! theoraenc ! theoradec ! queue max-size-buffers=3 ! xvimagesink

this gets worse as the quality setting is increased. on #gstreamer, thaytan suggested that theoraenc/dec weren't handling the latency query event properly as setting sync=false on xvimagesink yields smoother playback.
Comment 1 David Schleef 2009-09-18 21:04:26 UTC
Is your CPU fast enough to do a real-time encode at that size?  If not, you'll get frame dropping, which will end up looking choppy for a variety of reasons.
Comment 2 Tristan Matthews 2009-09-18 21:18:44 UTC
i think so, it's an intel quad core @ 2.40 ghz.
Comment 3 Filippo Argiolas 2009-09-21 07:26:00 UTC
I confirm the issue here with the first pipeline, it freezes after the first or second frame and prints tons of warnings like:

0:00:01.198691804  2773  0x8e63c78 WARN               theoradec theoradec.c:1430:theora_handle_data_packet:<theoradec0> dropping frame because of QoS

It works pretty fine if I set sync=false in xvimagesink (no noticeable speed loss nor dropped frames). I'm aware of at least another guy who had the same issue some time ago, CC-ing him.

The issue doesn't seem to happen with videotestsrc (maybe it's not the same issue of the reporter). Could it be related to my webcams outputting a couple of broken frames at the beginning (bug 587174)?
Comment 4 Sebastian Dröge (slomo) 2009-09-22 06:25:40 UTC
So the problem are probably broken timestamps from the v4l2src, which then trigger QoS and framedropping. Bug #595825 might help here
Comment 5 Stefan Sauer (gstreamer, gtkdoc dev) 2009-09-22 13:02:43 UTC
Not sure if bug #595825 is releated. There are two issues with the timestamping in v4l2 I am aware of:
1.) basetime is taken too early
2.) there is jitter in the timestamps as we stamp when we dequeue from userspace

The enhancement request I filed (and will work on) is related to the 2nd.
Comment 6 Vincent Penquerc'h 2011-10-26 12:16:17 UTC
This does not seem to be due to v4l2 timestamps, but simply the extra latency from Theora encoding.
On my machine (Intel i7 at... 2.7 GHz or 1.2 GHz, not sure if it speeds up when encoding, but it doesn't really matter), libtheora encodes a 640x480 frame in roughly:

default parameters: 0.1 seconds
quality=1 speed-level=4: 0.015 seconds

The second one yields fluid motion, albeit with bad quality. The first one, well... that's the same latency as 3 whole frames. Compare with the whole pipeline latency which was set to 0.03 - a third of the latency introduced by theoraenc.

Should elements such as encoders estimate and add their own latency to a latency query ? Those don't seem trivial to estimate, as latency will depend on frame complexity. Looking arbitrarily:
- schroenc does, but it looks like an inherent frame-based latency, not sure
- x264enc does not.
Comment 7 Tim-Philipp Müller 2013-04-21 09:44:38 UTC
I believe the GstVideoEncoder base class now tries to estimate its own latency.

However, I can still reproduce the issue with:

  gst-launch-1.0 -v v4l2src ! 'video/x-raw,width=640,height=480,framerate=30/1' ! queue ! theoraenc ! theoradec ! queue max-size-buffers=3 ! xvimagesink

The question is: is it actually a bug?

Arguably theoraenc is simply not fit for low latency use cases, at least not in our default configuration. (I have a vague memory of it taking very very long to encode some frames when there's rapid motion involved).
Comment 8 Sebastian Dröge (slomo) 2013-04-22 06:54:54 UTC
The video encoder base class has no code to estimate the latency, it still requires the subclass to tell it about the latency.
Comment 9 Tim-Philipp Müller 2014-11-28 20:35:40 UTC
Still an issue (with higher resolutions).
Comment 10 Nicolas Dufresne (ndufresne) 2014-11-28 21:42:04 UTC
Might be related to dyanmic framerate from v4l2src. A solution might be to reborn this old experiment:
https://bugzilla.gnome.org/show_bug.cgi?id=675761

If I remember, the main issue whas that it's not a perfect solution, you get some drops before the latency get updated. Also updating the latency will freeze the image for some time, and underflow shortly the audio.
Comment 11 GStreamer system administrator 2018-11-03 11:15:41 UTC
-- 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/gst-plugins-base/issues/24.