Re: Using gst-launch with ximagesrc says "There may be a timestamping problem, or this computer is too slow." - how do I solve this?

Alain Culos gstreamer at asoundmove.net
Mon Apr 6 23:52:51 UTC 2020


On Tue, 7 Apr 2020, at 00:11, Desouza, Ederson wrote:
> On Mon, 2020-04-06 at 23:16 +0100, Alain Culos wrote:
> > On Mon, 6 Apr 2020, at 21:44, Desouza, Ederson wrote:
> > > On Mon, 2020-04-06 at 20:39 +0100, Alain Culos wrote:
> > > > Thanks for this tip,
> > > > 
> > > > On Mon, 6 Apr 2020, at 17:26, Desouza, Ederson wrote:
> > > > > Hi,
> > > > > 
> > > > > On Sun, 2020-04-05 at 01:20 +0100, Alain Culos wrote:
> > > > > > Dear All,
> > > > > > 
> > > > > > I just discovered GStreamer, so apologies if this is a basic error, but no matter how hard I try I can't find what is wrong with my set-up / pipeline.
> > > > > > 
> > > > > > ===========
> > > > > > Summary:
> > > > > > When using ximagesrc, error messages appear to tell me buffers are lost and that there may be timestamping issues or that my computer is slow.
> > > > > 
> > > > > Have you tried using "use-damage=false" parameter on ximagesrc?
> > > > 
> > > > I had not, I now have.
> > > > 
> > > >     gst-launch-1.0   ximagesrc xid=0x02a00006 use-damage=false ! videoconvert ! autovideosink
> > > > 
> > > > The simple pipeline above now works flawlessly, with near real-time mirroring of the original window, great, now I need to make the more complex pipeline work better.
> > > > 
> > > > The mixer pipeline below, now updates about once per second (much better than without the "use-damage=false"), but still reports the timestamping error message.
> > > > 
> > > >     w=1280; h=800; x0=450; y0=200; gst-launch-1.0   \
> > > >         v4l2src device=/dev/video0 \
> > > >         ! videocrop left=$x0 right=$(( 1920 - $w - $x0 )) top=$y0 bottom=$(( 1080 - $h - $y0 )) \
> > > >         ! alpha method=green angle=70 \
> > > >         ! mixer.sink_1   \
> > > >         \
> > > >         ximagesrc xid=0x02a00006 use-damage=false ! videoscale \
> > > >         ! video/x-raw,width=$w,height=$h ! mixer.sink_0   \
> > > >         \
> > > >         videomixer name=mixer sink_0::zorder=0 sink_1::zorder=1 \
> > > >         ! videoconvert ! autovideosink
> > > > 
> > > 
> > > Try matching the framerate of both ximagesrc and v4l2src elements.
> > > Maybe add some queues to the pipeline too?
> > 
> > Admission: I have no idea how to use queues, the effect or impact they have.
> > Could it be a timestamping issue due to the fact that I do not carry the audio channel?
> > I so, I have no idea how to bring it in, I think I need a demux + mux, but which, how and where?
> 
> You can take a look at this link for a nice overview of queues:
> https://gstreamer.freedesktop.org/documentation/tutorials/basic/multithreading-and-pad-availability.html?gi-language=c
> I suggested it so that you may have more than on thread in your
> pipeline. It _may_ help - or not =D

Great resource, clear.
I moved both queues to the end of my pipelines, just before the input into the mixer sinks, it did not change anything.

> > Trying (see below, 2nd block, ximagesrc, 2nd line, framerate) and (2nd block, 1st line, queue) - one or the other or both - all yield the same result as previously:
> >     w=1280; h=800; x0=450; y0=200; gst-launch-1.0   \
> >         v4l2src device=/dev/video0 \
> >         ! videocrop left=$x0 right=$(( 1920 - $w - $x0 )) top=$y0 bottom=$(( 1080 - $h - $y0 )) \
> >         ! alpha method=green angle=70 \
> >         ! mixer.sink_1   \
> >         \
> >         ximagesrc xid=0x02a00006 use-damage=false ! queue ! videoscale \
> >         ! video/x-raw,width=$w,height=$h,framerate=30/1 ! mixer.sink_0   \
> >         \
> >         videomixer name=mixer sink_0::zorder=0 sink_1::zorder=1 \
> >         ! videoconvert ! autovideosink
> > 
> 
> I see that you fixed the framerate for the ximagesrc - are you sure
> that v4l2src has the same framerate? Anyway, another thing to try is to
> lower both framerates. You may need to use "videorate" element to
> reduce v4l2src framerate.

You were right to question the framerate.

I kept the queues and added "! videorate max-rate=5" (if I use rate instead of max-rate, it freezes the video output) after both ximagesrc and v42src, it made things worse (slower than 1 refresh per second) + same error messages.


> > Also tried with (alone and also with the queue after ximagesrc):
> >         v4l2src device=/dev/video0 ! queue \
> > 
> > Same result again.
> > 
> > > > Output:
> > > > 
> > > >     Setting pipeline to PAUSED ...
> > > >     Pipeline is live and does not need PREROLL ...
> > > >     Setting pipeline to PLAYING ...
> > > >     New clock: GstSystemClock
> > > > {
> > > >     WARNING: from element /GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0/GstXvImageSink:autovideosink0-actual-sink-xvimage: A lot of buffers are being dropped.
> > > >     Additional debug info:
> > > >     gstbasesink.c(2902): gst_base_sink_is_too_late (): /GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0/GstXvImageSink:autovideosink0-actual-sink-xvimage:
> > > >     There may be a timestamping problem, or this computer is too slow.
> > > > } * repeats every second or so.
> > > > 
> > > > Thanks & regards,
> > > > Alain.
> > > > 
> > > > 
> > > > > > I have a beefy desktop, 1yo i7, 6-core hyperthreaded, 64GB RAM ubuntu 18.04).
> > > > > > GStreamer 1.14.5
> > > > > > 
> > > > > > ===========
> > > > > > In detail:
> > > > > > 
> > > > > > The video shown with this command line is very laggy (it hardly uses any RAM or CPU // other note: my desktop easily copes with e.g. zoom meetings):
> > > > > > 
> > > > > >     gst-launch-1.0 autovideosrc ! videoconvert ! autovideosink # shows no error message
> > > > > >     gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert ! autovideosink # does exactly the same
> > > > > > 
> > > > > > 
> > > > > > Preparing the ground for chroma-keying a green screen background, this example works the same way the first two do (laggy but good quality & no error message showing):
> > > > > >     w=1280; h=800; x0=450; y0=200; gst-launch-1.0 \
> > > > > >         v4l2src device=/dev/video0 \
> > > > > >         ! videocrop left=$x0 right=$(( 1920 - $w - $x0 )) top=$y0 bottom=$(( 1080 - $h - $y0 )) \
> > > > > >         ! alpha method=green angle=70 \
> > > > > >         ! videoconvert \
> > > > > >         ! autovideosink
> > > > > > 
> > > > > > The background to replace the green screen will be taken from an application window.
> > > > > > This causes issues with buffers dropped & it complains about timestamping issues.
> > > > > >     gst-launch-1.0   ximagesrc xid=0x02a00006 ! videoconvert ! autovideosink
> > > > > > 
> > > > > > Below is the output of the command above:
> > > > > >     Setting pipeline to PAUSED ...
> > > > > >     Pipeline is live and does not need PREROLL ...
> > > > > >     Setting pipeline to PLAYING ...
> > > > > >     New clock: GstSystemClock
> > > > > >     WARNING: from element /GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0/GstXvImageSink:autovideosink0-actual-sink-xvimage: A lot of buffers are being dropped.
> > > > > >     Additional debug info:
> > > > > >     gstbasesink.c(2902): gst_base_sink_is_too_late (): /GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0/GstXvImageSink:autovideosink0-actual-sink-xvimage:
> > > > > >     There may be a timestamping problem, or this computer is too slow.
> > > > > > 
> > > > > > 
> > > > > > Even if I impose a low frame rate, it outputs the same error messages as above, command line:
> > > > > >     gst-launch-1.0   ximagesrc xid=0x02a00006 ! video/x-raw,framerate=5/1 ! videoconvert ! autovideosink
> > > > > > 
> > > > > > Obviously, if I combine the two, performance gets worse, despite still not hitting the CPU or RAM, and the following command shows exactly the same messages as above:
> > > > > >     w=1280; h=800; x0=450; y0=200; gst-launch-1.0   \
> > > > > >         v4l2src device=/dev/video0 \
> > > > > >         ! videocrop left=$x0 right=$(( 1920 - $w - $x0 )) top=$y0 bottom=$(( 1080 - $h - $y0 )) \
> > > > > >         ! alpha method=green angle=70 \
> > > > > >         ! mixer.sink_1   \
> > > > > >         \
> > > > > >         ximagesrc xid=0x02a00006 ! videoscale \
> > > > > >         ! video/x-raw,width=$w,height=$h ! mixer.sink_0   \
> > > > > >         \
> > > > > >         videomixer name=mixer sink_0::zorder=0 sink_1::zorder=1 \
> > > > > >         ! videoconvert ! autovideosink
> > > > > > 
> > > > > > Whether I put ximagesrc before v4l2src or after changes nothing.
> > > > > > 
> > > > > > (next challenges: 1/ channelling this to /dev/video10; 2/ channeling the audio from the webcam (/dev/video0) to the virtual webcam (dev/video10))
> > > > > > 
> > > > > > For now I  would most appreciate some help with making the above commands works without error/warning messages and good performance. Or in other words how do I resolve timestamping with ximagesrc?
> > > > > > 
> > > > > > Best regards,
> > > > > > Alain.
> > > > > > 
> > > > > > 
> > > > > > On Wed, 1 Apr 2020, at 02:42, Alain Culos wrote:
> > > > > > > Hi,
> > > > > > > 
> > > > > > > I am a recent newcomer to gstreamer.
> > > > > > > Trying to use `gst-launch-1.0` to chroma-key my webcam and insert a pdf 
> > > > > > > as background.
> > > > > > > 
> > > > > > > My attempt is very imperfect:
> > > > > > > 1/ I have not been able to find the right parameters to make the window 
> > > > > > > sizes match.
> > > > > > > 2/ gst-launch occasionally complains it loses a lot of buffers.
> > > > > > > 3/ the video output only updates seemingly randomly, infrequently, and 
> > > > > > > seems to (but not always) needs the pdf window to have focus and the 
> > > > > > > mouse to be over it (but not exclusively).
> > > > > > > 
> > > > > > > Maybe there is a better solution.
> > > > > > > My desktop is quite powerful: a modern (about 1yo, i7, 6-core, 
> > > > > > > hyperthreaded, 64GB RAM), 4k display, 1080p USB webcam, SSD.
> > > > > > > Linux 5.3.0-40-generic #32~18.04.1-Ubuntu SMP Mon Feb 3 14:05:59 UTC 
> > > > > > > 2020 x86_64 x86_64 x86_64 GNU/Linux
> > > > > > > ()
> > > > > > > 
> > > > > > > The commands I ran are:
> > > > > > > 
> > > > > > > 1/ testing the chroma-key with a chequered background
> > > > > > > gst-launch-1.0 \
> > > > > > >   videotestsrc pattern=checkers-8 ! video/x-raw,width=800,height=640 ! 
> > > > > > > mixer.sink_0 \
> > > > > > >   autovideosrc ! video/x-raw,width=800 ! alpha method=custom 
> > > > > > > target-r=255 target-g=255 target-b=255 ! mixer.sink_1 \
> > > > > > >   videomixer name=mixer sink_0::zorder=0 sink_1::zorder=1 ! 
> > > > > > > videoconvert ! autovideosink
> > > > > > > -> Very slow video, does not chroma-key on white!
> > > > > > > gst-launch recurrent message: "A lot of buffers are being dropped"
> > > > > > > 
> > > > > > > 2/ testing the chroma-key (2nd attempt)
> > > > > > > gst-launch-1.0 \
> > > > > > >   videotestsrc pattern=checkers-8 ! 
> > > > > > > video/x-raw,width=800,height=640,framerate=1/1 ! mixer.sink_0 \
> > > > > > >   autovideosrc ! video/x-raw,width=800 ! alpha method=custom 
> > > > > > > target-r=255 target-g=255 target-b=255 ! mixer.sink_1 \
> > > > > > >   videomixer name=mixer sink_0::zorder=0 sink_1::zorder=1 ! 
> > > > > > > videoconvert ! autovideosink
> > > > > > > -> Same as above
> > > > > > > 
> > > > > > > 3/ testing my video
> > > > > > > gst-launch-1.0 autovideosrc ! video/x-raw,width=800 ! videoconvert ! 
> > > > > > > autovideosink
> > > > > > > -> Showing my webcam is almost real-time, but has a bit of lag
> > > > > > > The same test at 1080p is very laggy
> > > > > > > 
> > > > > > > 4/ testing a source application window (evince, showing a pdf file)
> > > > > > > gst-launch-1.0 \
> > > > > > >   ximagesrc xid=0x06800008 ! mixer.sink_0 \
> > > > > > >   autovideosrc ! video/x-raw,width=800 ! alpha method=custom 
> > > > > > > target-r=255 target-g=255 target-b=255 ! mixer.sink_1 \
> > > > > > >   videomixer name=mixer sink_0::zorder=0 sink_1::zorder=1 ! 
> > > > > > > videoconvert ! autovideosink
> > > > > > > -> Does not update the video in realtime (only updates rarely, at most 
> > > > > > > every few seconds, when the application window has the focus or redraw 
> > > > > > > events (possibly and/or mouse over)), does not allow me to resize the 
> > > > > > > application window video stream.
> > > > > > > 
> > > > > > > 
> > > > > > > Hoping to find here some pointers to solve the issues highlighted 
> > > > > > > above, most importantly performance (framerate).
> > > > > > > 
> > > > > > > Next steps: a/ including the audio stream, b/ outputting to a video 
> > > > > > > device so I can use this as a source for a video conference 
> > > > > > > (zoom/skype/jitsi), c/ using an actual green screen.
> > > > > > > 
> > > > > > > Thanks for any help, pointers to documentation or tutorials.
> > > > > > > Regards,
> > > > > > > Alain.
> > > > > > > _______________________________________________
> > > > > > > gstreamer-devel mailing list
> > > > > > > gstreamer-devel at lists.freedesktop.org
> > > > > > > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> > > > > > > 
> > > > > > _______________________________________________
> > > > > > gstreamer-devel mailing list
> > > > > > gstreamer-devel at lists.freedesktop.org
> > > > > > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> > > > > _______________________________________________
> > > > > gstreamer-devel mailing list
> > > > > gstreamer-devel at lists.freedesktop.org
> > > > > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> > > > > 
> > > > _______________________________________________
> > > > gstreamer-devel mailing list
> > > > gstreamer-devel at lists.freedesktop.org
> > > > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> > > _______________________________________________
> > > gstreamer-devel mailing list
> > > gstreamer-devel at lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> > > 
> > _______________________________________________
> > gstreamer-devel mailing list
> > gstreamer-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>


More information about the gstreamer-devel mailing list