I am trying to add a dynamic SVG overlay on a video stream using GStreamer. This is necessary because the data on our SVG can change and this change should be reflected on the stream.
The static approach can be achieved by giving the SVG file location:
appsrc name=Src ! videoflip method=5 ! videoconvert ! rsvgoverlay location=/logo.svg ! videoconvert ! glimagesink
This results in the SVG file overlaid on the videostream.
To make it dynamic, I tried to feed the SVG data through the rsvgoverlay data_sink pad, which in turn receives data from udpsrc:
appsrc name=Src ! videoflip method=5 ! videoconvert ! rsvgoverlay name=overlay ! videoconvert ! glimagesink udpsrc port=5005 address=127.0.0.1 ! tee name=t ! queue ! fakesink dump=true t. ! queue ! overlay.data_sink
There are extra commands for debugging purposes, to dump the SVG packet data after receiving it.
However, even though the SVG data is correctly received and dumped, the overlay does not show up on the stream.
Could this be a limitation of the rsvgoverlay element, or is there another way to approach this problem?
I use a Python script to send the SVG data:
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(open("/logo.svg", 'rb').read(), ("127.0.0.1", 5005))
I also tried just using the standard static approach, and physically changing the SVG. However I think the rsvgoverlay element caches the SVG and will not read it from the disk again after the first time. This did not work.
I tried a similar approach to the static method but with a filesrc element instead, but this also does not work, any changes to the SVG are not reflected on the stream.
appsrc name=Src ! videoflip method=5 ! videoconvert ! rsvgoverlay name=overlay ! videoconvert ! glimagesink filesrc location=/logo.svg ! image/svg ! overlay.data_sink
The udpsrc approach seems the most convinient, however it does not produce any results, the SVG does not show up on the stream at all.
appsrc name=Src ! videoflip method=5 ! videoconvert ! rsvgoverlay name=overlay ! videoconvert ! glimagesink udpsrc port=5005 address=127.0.0.1 ! tee name=t ! queue ! fakesink dump=true t. ! queue ! overlay.data_sink
I would expect the SVG overlay to show up, once it’s been received from the UDP source. I would also expect the SVG overlay to update dynamically, when a new SVG is sent over UDP.
Martin Reinok is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.