How to add text on gstreamer except textoverlay ?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

How to add text on gstreamer except textoverlay ?

ToanVnET
This post was updated on .
Hi,
I'm using textoverlay to add dynamic text in GStreamer. But the problem is
it takes quite lot of CPU usage.
Assume that, I only record video --> CPU usage about 3-5 %. But when I add
textoverlay, It can reached up to 20% at peak.

This is how I add dynamic text:
First, I create a timeout_callback function. In there, I use g_object_set to
set textoverlay content.  Then I use g_timeout_add_seconds_full function to
create an event each 1 sec and call timeout_callback function.

So, is there any way to add dynamic text in GStreamer without using
textoverlay ? Or, there is a problem with the way I do dynamic text ?

Please help me !



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to add text on gstreamer except textoverlay ?

gotsring
Can you change the video format of the incoming buffers to RGBA? That helps
CPU usage a great deal.
Otherwise, there's opencvtextoverlay, or do a search for others using
gst-inspect-1.0 | grep text



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to add text on gstreamer except textoverlay ?

Nicolas Dufresne-5
In reply to this post by ToanVnET
Le mardi 08 septembre 2020 à 23:46 -0500, ToanVnET a écrit :
> Hi,
> I'm using textoverlay to add dynamic text in GStreamer. But the problem is
> it takes quite lot of CPU usage.
> Assume that, I only record video --> CPU usage about 3-5 %. But when I add
> textoverlay, It can reached up to 20% at peak.

If you only display the text, you can use a capable videosink to get
the overlay rendering offloaded to the sink. glimagesink, gtkglsink,
qmlglsink do supports this. You also get higher quality text, since the
render will be done according to your display size.

>
> This is how I add dynamic text:
> First, I create a timeout_callback function. In there, I use g_object_set to
> set textoverlay content.  Then I use g_timeout_add_seconds_full function to
> create an event each 1 sec and call timeout_callback function.
>
> So, it there any way to add dynamic text in GStreamer without using
> textoverlay ? Or, there is a problem with the way I do dynamic text ?
>
> Please help me !
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to add text on gstreamer except textoverlay ?

ToanVnET
Thank for the advise. I'm using splitmuxsink to write multi video with mp4mux
and filesink. It's mean I need to write video *.mp4. Therefore, glimagesink,
gtkglsink, qmlglsink are not compatible.



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to add text on gstreamer except textoverlay ?

ToanVnET
In reply to this post by gotsring
Hi,
How can I change the video format of the incoming buffers to RGBA ? Did you
mean change thhis: "video/x-raw,format=(string)NV12" --->
"video/x-raw,format=(string)RGBA" ?




--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to add text on gstreamer except textoverlay ?

gotsring
ToanVnET wrote
> How can I change the video format of the incoming buffers to RGBA ? Did
> you
> mean change thhis: "video/x-raw,format=(string)NV12" --->
> "video/x-raw,format=(string)RGBA" ?

Something like that. The caps specified upstream of textoverlay should
specify RGBA. This might require adding a videoconvert/nvvidconv or
something like that right before the textoverlay element. It would help if
you posted your pipeline and the OS/hardware you're using.

Also note that I only mention RGBA because I was able to test it quickly
using gst-launch, but you can test and use other video formats if needed. Do
a gst-inspect on textoverlay to list supported formats.




--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to add text on gstreamer except textoverlay ?

ToanVnET

Unfortunately, It's not working in my case. This is how I set:

g_object_set(G_OBJECT(frameratefilter), "caps",
gst_caps_from_string("video/x-raw,format=(string)RGBA,width=1280,height=720,framerate=(fraction)30/1"),
NULL);
...
this is my pipeline:

source -> frameratefilter -> videoconvert -> overlay -> encoder -> filesink

One things I agree with your opinion, If I change the format type, the CPU
usage will be changed also. And seem like NV12 is the format which take  CPU
less than other types.



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to add text on gstreamer except textoverlay ?

Gary Metalle
Hi

You need to set the caps further downstream not on the frameratefilter, but on say the overlay. You have set the caps to indicate that the source is RGBA but this will only work if the source is actually RGBA. I would try something like this...

g_object_set(G_OBJECT(frameratefilter), "caps",
gst_caps_from_string("video/x-raw,width=1280,height=720,framerate=(fraction)30/1"),
NULL);

g_object_set(G_OBJECT(overlay), "caps",
gst_caps_from_string("video/x-raw,width=1280,format=(string)RGBA,height=720,framerate=(fraction)30/1"),
NULL);

This way you are telling the videoconvert that you want RGBA format going into the overlay block and if the format from the source is NV12 or anything other than RBGA, then it will convert it for you (otherwise it will pass the buffers through untouched).

________________________________________
From: gstreamer-devel <[hidden email]> on behalf of ToanVnET <[hidden email]>
Sent: 12 September 2020 02:42
To: [hidden email]
Subject: Re: How to add text on gstreamer except textoverlay ?

Unfortunately, It's not working in my case. This is how I set:

g_object_set(G_OBJECT(frameratefilter), "caps",
gst_caps_from_string("video/x-raw,format=(string)RGBA,width=1280,height=720,framerate=(fraction)30/1"),
NULL);
...
this is my pipeline:

source -> frameratefilter -> videoconvert -> overlay -> encoder -> filesink

One things I agree with your opinion, If I change the format type, the CPU
usage will be changed also. And seem like NV12 is the format which take  CPU
less than other types.



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel