Dynamic text-overlay on live-stream using gst-launch-1.0

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

Dynamic text-overlay on live-stream using gst-launch-1.0

Adam Plocher
Hello, I apologize if I'm posting this in the wrong place. I've previously asked this on stackoverflow and never got a response: http://stackoverflow.com/questions/42128804/polling-a-text-file-and-overlaying-the-result-in-gstreamer

I have a Raspberry Pi with a camera and I'm live streaming that back to another unit (it's for a baby monitor).  On the same Pi, I have a temperature sensor that is dumping the current temp to a file every 5 seconds.

My question: Is it possible to somehow poll that txt file and update a text-overlay on the live stream based on the current contents of that file?

I've tried using a filesrc and subparse, and it will grab it initially if I format the input text file properly, but it doesn't seem to update itself:

gst-launch-1.0 -v \
    filesrc location=/home/pi/temp.txt ! subparse ! txt. rpicamsrc awb-mode=0 awb-gain-red=1 awb-gain-blue=2 rotation=0 bitrate=820000 preview=false brightness=67 contrast=30 sharpness=40 \
    ! video/x-h264,width=800,height=480,framerate=10/1 \
    ! h264parse ! decodebin ! videoconvert ! clockoverlay shaded-background=true draw-shadow=true font-desc="Nimbus Mono" \
    ! textoverlay name=txt shaded-background=yes \
    ! omxh264enc control-rate=3 target-bitrate=850000 \
    ! tcpserversink host=0.0.0.0 port=5555 sync=true

The input file looks like this:
1
00:00:00,000 --> 99:59:59,000
69 degrees
Thank you!

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

Re: Dynamic text-overlay on live-stream using gst-launch-1.0

Nicolas Dufresne-5
Le dimanche 26 février 2017 à 06:18 -0800, Adam Plocher a écrit :

> Hello, I apologize if I'm posting this in the wrong place. I've
> previously asked this on stackoverflow and never got a response: http
> ://stackoverflow.com/questions/42128804/polling-a-text-file-and-
> overlaying-the-result-in-gstreamer
>
> I have a Raspberry Pi with a camera and I'm live streaming that back
> to another unit (it's for a baby monitor).  On the same Pi, I have a
> temperature sensor that is dumping the current temp to a file every 5
> seconds.
>
> My question: Is it possible to somehow poll that txt file and update
> a text-overlay on the live stream based on the current contents of
> that file?
filsesrc does not have this feature unfortunatly. I believe using
fdsrc, you could:

  tail -f text.txt | gst-launch-1.0 fdsrc ! ...

Let me know if that is a good work-around. If you are writing an app,
this can be done with a pipe, or if you prefer, with appsrc.

>
> I've tried using a filesrc and subparse, and it will grab it
> initially if I format the input text file properly, but it doesn't
> seem to update itself:
>
> gst-launch-1.0 -v \
>     filesrc location=/home/pi/temp.txt ! subparse ! txt. rpicamsrc
> awb-mode=0 awb-gain-red=1 awb-gain-blue=2 rotation=0 bitrate=820000
> preview=false brightness=67 contrast=30 sharpness=40 \
>     ! video/x-h264,width=800,height=480,framerate=10/1 \
>     ! h264parse ! decodebin ! videoconvert ! clockoverlay shaded-
> background=true draw-shadow=true font-desc="Nimbus Mono" \
>     ! textoverlay name=txt shaded-background=yes \
>     ! omxh264enc control-rate=3 target-bitrate=850000 \
>     ! tcpserversink host=0.0.0.0 port=5555 sync=true
>
> The input file looks like this:
> 1
> 00:00:00,000 --> 99:59:59,000
> 69 degrees
> Thank you!
> _______________________________________________
> 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

signature.asc (188 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic text-overlay on live-stream using gst-launch-1.0

filnet
You can also connect the text overlay element to an udpsrc element.

And then use the tools of the trade to send your text file as udp packets.
For example (not tested at all) : tail -f <file> > /dev/udp/127.0.0.1/<port>
There are other ways to send udp packets (netcat, Packet Sender, ...).

An advantage of this approach is that it decouples your pipeline from the text overlay source.
So you can start/stop it without having to start/stop the pipeline.

Note that textoverlay supports pango-markup. This allows you to send more than just plain text if you need to.


Le Lundi 27 février 2017 6h18, Nicolas Dufresne <[hidden email]> a écrit :


Le dimanche 26 février 2017 à 06:18 -0800, Adam Plocher a écrit :

> Hello, I apologize if I'm posting this in the wrong place. I've
> previously asked this on stackoverflow and never got a response: http
> ://stackoverflow.com/questions/42128804/polling-a-text-file-and-
> overlaying-the-result-in-gstreamer
>
> I have a Raspberry Pi with a camera and I'm live streaming that back
> to another unit (it's for a baby monitor).  On the same Pi, I have a
> temperature sensor that is dumping the current temp to a file every 5
> seconds.
>
> My question: Is it possible to somehow poll that txt file and update
> a text-overlay on the live stream based on the current contents of
> that file?

filsesrc does not have this feature unfortunatly. I believe using
fdsrc, you could:

  tail -f text.txt | gst-launch-1.0 fdsrc ! ...

Let me know if that is a good work-around. If you are writing an app,
this can be done with a pipe, or if you prefer, with appsrc.


>
> I've tried using a filesrc and subparse, and it will grab it
> initially if I format the input text file properly, but it doesn't
> seem to update itself:
>
> gst-launch-1.0 -v \
>     filesrc location=/home/pi/temp.txt ! subparse ! txt. rpicamsrc
> awb-mode=0 awb-gain-red=1 awb-gain-blue=2 rotation=0 bitrate=820000
> preview=false brightness=67 contrast=30 sharpness=40 \
>     ! video/x-h264,width=800,height=480,framerate=10/1 \
>     ! h264parse ! decodebin ! videoconvert ! clockoverlay shaded-
> background=true draw-shadow=true font-desc="Nimbus Mono" \
>     ! textoverlay name=txt shaded-background=yes \
>     ! omxh264enc control-rate=3 target-bitrate=850000 \
>     ! tcpserversink host=0.0.0.0 port=5555 sync=true
>
> The input file looks like this:
> 1
> 00:00:00,000 --> 99:59:59,000
> 69 degrees
> Thank you!
> _______________________________________________
> 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



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

Re: Dynamic text-overlay on live-stream using gst-launch-1.0

Adam Plocher
In reply to this post by Nicolas Dufresne-5
Nicolas, thank you for your response.  fdsrc seems like it would be a good solution, but I'm having issues getting it to work.

It seems like I need to specify the caps after the fdsrc, otherwise it fails in other ways.  e.g.


Specifying text/x-raw:

tail -f /home/pi/test.txt | /opt/gst/bin/gst-launch-1.0 fdsrc fd=0 ! "text/x-raw" ! txt. videotestsrc ! videoconvert ! decodebin ! textoverlay name=txt ! omxh264enc target-bitrate=800000 control-rate=3 ! tcpserversink host=0.0.0.0 port=9000

Results in:

Pipeline is PREROLLING ...
ERROR: from element /GstPipeline:pipeline0/GstCapsFilter:capsfilter0: Filter caps do not completely specify the output format
Additional debug info:
gstcapsfilter.c(455): gst_capsfilter_prepare_buf (): /GstPipeline:pipeline0/GstCapsFilter:capsfilter0:
Output caps are unfixed: text/x-raw, format=(string){ pango-markup, utf8 }
ERROR: pipeline doesn't want to preroll.


Specifying text/plain:

tail -f /home/pi/test.txt | /opt/gst/bin/gst-launch-1.0 fdsrc fd=0 ! "text/plain" ! txt. videotestsrc ! videoconvert ! decodebin ! textoverlay name=txt ! omxh264enc target-bitrate=800000 control-rate=3 ! tcpserversink host=0.0.0.0 port=9000

Results in:

0:00:00.501757360  4549  0x1e085c0 ERROR           GST_PIPELINE grammar.y:714:gst_parse_perform_link: could not link fdsrc0 to txt, txt can't handle caps text/plain
WARNING: erroneous pipeline: could not link fdsrc0 to txt, txt can't handle caps text/plain


No caps at all:

tail -f /home/pi/test.txt | /opt/gst/bin/gst-launch-1.0 fdsrc fd=0 ! txt. videotestsrc ! videoconvert ! decodebin ! textoverlay name=txt !  omxh264enc target-bitrate=800000 control-rate=3 ! tcpserversink host=0.0.0.0 port=9000

Results in:

Pipeline is PREROLLING ...
WARNING: from element /GstPipeline:pipeline0/GstTextOverlay:txt: Could not multiplex stream.
Additional debug info:
gstbasetextoverlay.c(2449): gst_base_text_overlay_video_event (): /GstPipeline:pipeline0/GstTextOverlay:txt:
received non-TIME newsegment event on video input
WARNING: from element /GstPipeline:pipeline0/GstDecodeBin:decodebin0: Delayed linking failed.
Additional debug info:
./grammar.y(510): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstDecodeBin:decodebin0:
failed delayed linking some pad of GstDecodeBin named decodebin0 to some pad of GstTextOverlay named txt
ERROR: from element /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0: Internal data stream error.
Additional debug info:
gstbasesrc.c(2951): gst_base_src_loop (): /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0:
streaming stopped, reason not-linked (-1)
ERROR: pipeline doesn't want to preroll.


There is some information here (regarding the older version of gst-launch): 

And that links to this bug that was resolved (again, old gst-launch): 


I've seen a couple examples which used the "text/plain" caps.

I'm certainly open to cracking open the Python lib and giving it a shot.  I would need to read up on it a bit and I'm not familiar with the appsrc, either, but that's something else I'm open to. I have done very basic stuff with the Python libs but nothing too fancy or dynamic (basic pipelines, no more complex than I would get from gst-launch-1.0).

What would you recommend?  Is there an example or resource you could point me towards?

Thank you for your help


On Sun, Feb 26, 2017 at 2:46 PM, Nicolas Dufresne <[hidden email]> wrote:
Le dimanche 26 février 2017 à 06:18 -0800, Adam Plocher a écrit :
> Hello, I apologize if I'm posting this in the wrong place. I've
> previously asked this on stackoverflow and never got a response: http
> ://stackoverflow.com/questions/42128804/polling-a-text-file-and-
> overlaying-the-result-in-gstreamer
>
> I have a Raspberry Pi with a camera and I'm live streaming that back
> to another unit (it's for a baby monitor).  On the same Pi, I have a
> temperature sensor that is dumping the current temp to a file every 5
> seconds.
>
> My question: Is it possible to somehow poll that txt file and update
> a text-overlay on the live stream based on the current contents of
> that file?

filsesrc does not have this feature unfortunatly. I believe using
fdsrc, you could:

  tail -f text.txt | gst-launch-1.0 fdsrc ! ...

Let me know if that is a good work-around. If you are writing an app,
this can be done with a pipe, or if you prefer, with appsrc.

>
> I've tried using a filesrc and subparse, and it will grab it
> initially if I format the input text file properly, but it doesn't
> seem to update itself:
>
> gst-launch-1.0 -v \
>     filesrc location=/home/pi/temp.txt ! subparse ! txt. rpicamsrc
> awb-mode=0 awb-gain-red=1 awb-gain-blue=2 rotation=0 bitrate=820000
> preview=false brightness=67 contrast=30 sharpness=40 \
>     ! video/x-h264,width=800,height=480,framerate=10/1 \
>     ! h264parse ! decodebin ! videoconvert ! clockoverlay shaded-
> background=true draw-shadow=true font-desc="Nimbus Mono" \
>     ! textoverlay name=txt shaded-background=yes \
>     ! omxh264enc control-rate=3 target-bitrate=850000 \
>     ! tcpserversink host=0.0.0.0 port=5555 sync=true
>
> The input file looks like this:
> 1
> 00:00:00,000 --> 99:59:59,000
> 69 degrees
> Thank you!
> _______________________________________________
> 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



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

Re: Dynamic text-overlay on live-stream using gst-launch-1.0

Nicolas Dufresne-5
Le lundi 27 février 2017 à 07:05 -0800, Adam Plocher a écrit :
Nicolas, thank you for your response.  fdsrc seems like it would be a good solution, but I'm having issues getting it to work.

It seems like I need to specify the caps after the fdsrc, otherwise it fails in other ways.  e.g.


Specifying text/x-raw:

tail -f /home/pi/test.txt | /opt/gst/bin/gst-launch-1.0 fdsrc fd=0 ! "text/x-raw" ! txt. videotestsrc ! videoconvert ! decodebin ! textoverlay name=txt ! omxh264enc target-bitrate=800000 control-rate=3 ! tcpserversink host=0.0.0.0 port=9000

I think you forgot to keep subparse element.


Results in:

Pipeline is PREROLLING ...
ERROR: from element /GstPipeline:pipeline0/GstCapsFilter:capsfilter0: Filter caps do not completely specify the output format
Additional debug info:
gstcapsfilter.c(455): gst_capsfilter_prepare_buf (): /GstPipeline:pipeline0/GstCapsFilter:capsfilter0:
Output caps are unfixed: text/x-raw, format=(string){ pango-markup, utf8 }
ERROR: pipeline doesn't want to preroll.


Specifying text/plain:

tail -f /home/pi/test.txt | /opt/gst/bin/gst-launch-1.0 fdsrc fd=0 ! "text/plain" ! txt. videotestsrc ! videoconvert ! decodebin ! textoverlay name=txt ! omxh264enc target-bitrate=800000 control-rate=3 ! tcpserversink host=0.0.0.0 port=9000

Results in:

0:00:00.501757360  4549  0x1e085c0 ERROR           GST_PIPELINE grammar.y:714:gst_parse_perform_link: could not link fdsrc0 to txt, txt can't handle caps text/plain
WARNING: erroneous pipeline: could not link fdsrc0 to txt, txt can't handle caps text/plain


No caps at all:

tail -f /home/pi/test.txt | /opt/gst/bin/gst-launch-1.0 fdsrc fd=0 ! txt. videotestsrc ! videoconvert ! decodebin ! textoverlay name=txt !  omxh264enc target-bitrate=800000 control-rate=3 ! tcpserversink host=0.0.0.0 port=9000

Results in:

Pipeline is PREROLLING ...
WARNING: from element /GstPipeline:pipeline0/GstTextOverlay:txt: Could not multiplex stream.
Additional debug info:
gstbasetextoverlay.c(2449): gst_base_text_overlay_video_event (): /GstPipeline:pipeline0/GstTextOverlay:txt:
received non-TIME newsegment event on video input
WARNING: from element /GstPipeline:pipeline0/GstDecodeBin:decodebin0: Delayed linking failed.
Additional debug info:
./grammar.y(510): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstDecodeBin:decodebin0:
failed delayed linking some pad of GstDecodeBin named decodebin0 to some pad of GstTextOverlay named txt
ERROR: from element /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0: Internal data stream error.
Additional debug info:
gstbasesrc.c(2951): gst_base_src_loop (): /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0:
streaming stopped, reason not-linked (-1)
ERROR: pipeline doesn't want to preroll.


There is some information here (regarding the older version of gst-launch): 

And that links to this bug that was resolved (again, old gst-launch): 


I've seen a couple examples which used the "text/plain" caps.

I'm certainly open to cracking open the Python lib and giving it a shot.  I would need to read up on it a bit and I'm not familiar with the appsrc, either, but that's something else I'm open to. I have done very basic stuff with the Python libs but nothing too fancy or dynamic (basic pipelines, no more complex than I would get from gst-launch-1.0).

What would you recommend?  Is there an example or resource you could point me towards?

Thank you for your help


On Sun, Feb 26, 2017 at 2:46 PM, Nicolas Dufresne <[hidden email]> wrote:
Le dimanche 26 février 2017 à 06:18 -0800, Adam Plocher a écrit :
> Hello, I apologize if I'm posting this in the wrong place. I've
> previously asked this on stackoverflow and never got a response: http
> ://stackoverflow.com/questions/42128804/polling-a-text-file-and-
> overlaying-the-result-in-gstreamer
>
> I have a Raspberry Pi with a camera and I'm live streaming that back
> to another unit (it's for a baby monitor).  On the same Pi, I have a
> temperature sensor that is dumping the current temp to a file every 5
> seconds.
>
> My question: Is it possible to somehow poll that txt file and update
> a text-overlay on the live stream based on the current contents of
> that file?

filsesrc does not have this feature unfortunatly. I believe using
fdsrc, you could:

  tail -f text.txt | gst-launch-1.0 fdsrc ! ...

Let me know if that is a good work-around. If you are writing an app,
this can be done with a pipe, or if you prefer, with appsrc.

>
> I've tried using a filesrc and subparse, and it will grab it
> initially if I format the input text file properly, but it doesn't
> seem to update itself:
>
> gst-launch-1.0 -v \
>     filesrc location=/home/pi/temp.txt ! subparse ! txt. rpicamsrc
> awb-mode=0 awb-gain-red=1 awb-gain-blue=2 rotation=0 bitrate=820000
> preview=false brightness=67 contrast=30 sharpness=40 \
>     ! video/x-h264,width=800,height=480,framerate=10/1 \
>     ! h264parse ! decodebin ! videoconvert ! clockoverlay shaded-
> background=true draw-shadow=true font-desc="Nimbus Mono" \
>     ! textoverlay name=txt shaded-background=yes \
>     ! omxh264enc control-rate=3 target-bitrate=850000 \
>     ! tcpserversink host=0.0.0.0 port=5555 sync=true
>
> The input file looks like this:
> 1
> 00:00:00,000 --> 99:59:59,000
> 69 degrees
> Thank you!
> _______________________________________________
> 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


_______________________________________________
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

signature.asc (188 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic text-overlay on live-stream using gst-launch-1.0



Le Lundi 27 février 2017 16h34, Nicolas Dufresne <[hidden email]> a écrit :


Le lundi 27 février 2017 à 07:05 -0800, Adam Plocher a écrit :
Nicolas, thank you for your response.  fdsrc seems like it would be a good solution, but I'm having issues getting it to work.

It seems like I need to specify the caps after the fdsrc, otherwise it fails in other ways.  e.g.


Specifying text/x-raw:

tail -f /home/pi/test.txt | /opt/gst/bin/gst-launch-1.0 fdsrc fd=0 ! "text/x-raw" ! txt. videotestsrc ! videoconvert ! decodebin ! textoverlay name=txt ! omxh264enc target-bitrate=800000 control-rate=3 ! tcpserversink host=0.0.0.0 port=9000

I think you forgot to keep subparse element.


Results in:

Pipeline is PREROLLING ...
ERROR: from element /GstPipeline:pipeline0/GstCapsFilter:capsfilter0: Filter caps do not completely specify the output format
Additional debug info:
gstcapsfilter.c(455): gst_capsfilter_prepare_buf (): /GstPipeline:pipeline0/GstCapsFilter:capsfilter0:
Output caps are unfixed: text/x-raw, format=(string){ pango-markup, utf8 }
ERROR: pipeline doesn't want to preroll.


Specifying text/plain:

tail -f /home/pi/test.txt | /opt/gst/bin/gst-launch-1.0 fdsrc fd=0 ! "text/plain" ! txt. videotestsrc ! videoconvert ! decodebin ! textoverlay name=txt ! omxh264enc target-bitrate=800000 control-rate=3 ! tcpserversink host=0.0.0.0 port=9000

Results in:

0:00:00.501757360  4549  0x1e085c0 ERROR           GST_PIPELINE grammar.y:714:gst_parse_perform_link: could not link fdsrc0 to txt, txt can't handle caps text/plain
WARNING: erroneous pipeline: could not link fdsrc0 to txt, txt can't handle caps text/plain


No caps at all:

tail -f /home/pi/test.txt | /opt/gst/bin/gst-launch-1.0 fdsrc fd=0 ! txt. videotestsrc ! videoconvert ! decodebin ! textoverlay name=txt !  omxh264enc target-bitrate=800000 control-rate=3 ! tcpserversink host=0.0.0.0 port=9000

Results in:

Pipeline is PREROLLING ...
WARNING: from element /GstPipeline:pipeline0/GstTextOverlay:txt: Could not multiplex stream.
Additional debug info:
gstbasetextoverlay.c(2449): gst_base_text_overlay_video_event (): /GstPipeline:pipeline0/GstTextOverlay:txt:
received non-TIME newsegment event on video input
WARNING: from element /GstPipeline:pipeline0/GstDecodeBin:decodebin0: Delayed linking failed.
Additional debug info:
./grammar.y(510): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstDecodeBin:decodebin0:
failed delayed linking some pad of GstDecodeBin named decodebin0 to some pad of GstTextOverlay named txt
ERROR: from element /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0: Internal data stream error.
Additional debug info:
gstbasesrc.c(2951): gst_base_src_loop (): /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0:
streaming stopped, reason not-linked (-1)
ERROR: pipeline doesn't want to preroll.


There is some information here (regarding the older version of gst-launch): 

And that links to this bug that was resolved (again, old gst-launch): 


I've seen a couple examples which used the "text/plain" caps.

I'm certainly open to cracking open the Python lib and giving it a shot.  I would need to read up on it a bit and I'm not familiar with the appsrc, either, but that's something else I'm open to. I have done very basic stuff with the Python libs but nothing too fancy or dynamic (basic pipelines, no more complex than I would get from gst-launch-1.0).

What would you recommend?  Is there an example or resource you could point me towards?

Thank you for your help


On Sun, Feb 26, 2017 at 2:46 PM, Nicolas Dufresne <[hidden email]> wrote:
Le dimanche 26 février 2017 à 06:18 -0800, Adam Plocher a écrit :
> Hello, I apologize if I'm posting this in the wrong place. I've
> previously asked this on stackoverflow and never got a response: http
> ://stackoverflow.com/ questions/42128804/polling-a- text-file-and-
> overlaying-the-result-in- gstreamer
>
> I have a Raspberry Pi with a camera and I'm live streaming that back
> to another unit (it's for a baby monitor).  On the same Pi, I have a
> temperature sensor that is dumping the current temp to a file every 5
> seconds.
>
> My question: Is it possible to somehow poll that txt file and update
> a text-overlay on the live stream based on the current contents of
> that file?

filsesrc does not have this feature unfortunatly. I believe using
fdsrc, you could:

  tail -f text.txt | gst-launch-1.0 fdsrc ! ...

Let me know if that is a good work-around. If you are writing an app,
this can be done with a pipe, or if you prefer, with appsrc.

>
> I've tried using a filesrc and subparse, and it will grab it
> initially if I format the input text file properly, but it doesn't
> seem to update itself:
>
> gst-launch-1.0 -v \
>     filesrc location=/home/pi/temp.txt ! subparse ! txt. rpicamsrc
> awb-mode=0 awb-gain-red=1 awb-gain-blue=2 rotation=0 bitrate=820000
> preview=false brightness=67 contrast=30 sharpness=40 \
>     ! video/x-h264,width=800,height= 480,framerate=10/1 \
>     ! h264parse ! decodebin ! videoconvert ! clockoverlay shaded-
> background=true draw-shadow=true font-desc="Nimbus Mono" \
>     ! textoverlay name=txt shaded-background=yes \
>     ! omxh264enc control-rate=3 target-bitrate=850000 \
>     ! tcpserversink host=0.0.0.0 port=5555 sync=true
>
> The input file looks like this:
> 1
> 00:00:00,000 --> 99:59:59,000
> 69 degrees
> Thank you!
> ______________________________ _________________
> 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


_______________________________________________
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



_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
filnet
textoverlay accepts caps defined as:
text/x-raw, format=(string){ pango-markup, utf8 }

may be you need to set caps to "text/x-raw, format=utf8" or something along those line.
Reply | Threaded
Open this post in threaded view
|

RE: Dynamic text-overlay on live-stream using gst-launch-1.0

Adam Plocher
In reply to this post by Nicolas Dufresne-5

Thanks again Nicolas.  I feel like I’m getting very close.  Here’s what I have right now, and this basically kinda sorta works:

 

tail -n 1000 -f /home/pi/test.txt | /opt/gst/bin/gst-launch-1.0 -v fdsrc ! subparse ! txt. videotestsrc is-live=true ! video/x-raw, width =800, height=480, framerate=10/1 ! videoconvert ! decodebin ! textoverlay name=txt !  omxh264enc target-bitrate=800000 control-rate=3 ! tcpserversink host=0.0.0.0 port=9000

 

I can inject items to test.txt from the shell like this:

 

printf "7\n00:01:59,826 --> 00:02:59,000\nNOW I SAY WORK\n\n" >> /home/pi/test.txt

 

Now my challenge is, how do I post the proper time ranges?  Unfortunately it seems I can’t keep appending 00:00:00,000 --> 99:99:99,000 because it will only show one subtitle at a time and it seems to always be the first one for that time-range.  So the second sub-title wouldn’t overwrite the first one (which is basically what I need).

 

So I think these are my options:

-          Is there another format or something that the subtitles can be written in?

-          Or a way to cause newer sub-titles take precedence over older ones?

-          Or am I going to need to keep track of the play-time from my secondary process and regularly append accurate times to the file/stdout?

 

Thank you

-Adam

 

From: gstreamer-devel [mailto:[hidden email]] On Behalf Of Nicolas Dufresne
Sent: Monday, February 27, 2017 7:34 AM
To: Discussion of the development of and with GStreamer <[hidden email]>
Subject: Re: Dynamic text-overlay on live-stream using gst-launch-1.0

 

Le lundi 27 février 2017 à 07:05 -0800, Adam Plocher a écrit :

Nicolas, thank you for your response.  fdsrc seems like it would be a good solution, but I'm having issues getting it to work.

 

It seems like I need to specify the caps after the fdsrc, otherwise it fails in other ways.  e.g.

 

 

Specifying text/x-raw:

 

tail -f /home/pi/test.txt | /opt/gst/bin/gst-launch-1.0 fdsrc fd=0 ! "text/x-raw" ! txt. videotestsrc ! videoconvert ! decodebin ! textoverlay name=txt ! omxh264enc target-bitrate=800000 control-rate=3 ! tcpserversink host=0.0.0.0 port=9000

 

I think you forgot to keep subparse element.

 

 

Results in:

 

Pipeline is PREROLLING ...

ERROR: from element /GstPipeline:pipeline0/GstCapsFilter:capsfilter0: Filter caps do not completely specify the output format

Additional debug info:

gstcapsfilter.c(455): gst_capsfilter_prepare_buf (): /GstPipeline:pipeline0/GstCapsFilter:capsfilter0:

Output caps are unfixed: text/x-raw, format=(string){ pango-markup, utf8 }

ERROR: pipeline doesn't want to preroll.

 

 

Specifying text/plain:

 

tail -f /home/pi/test.txt | /opt/gst/bin/gst-launch-1.0 fdsrc fd=0 ! "text/plain" ! txt. videotestsrc ! videoconvert ! decodebin ! textoverlay name=txt ! omxh264enc target-bitrate=800000 control-rate=3 ! tcpserversink host=0.0.0.0 port=9000

 

Results in:

 

0:00:00.501757360  4549  0x1e085c0 ERROR           GST_PIPELINE grammar.y:714:gst_parse_perform_link: could not link fdsrc0 to txt, txt can't handle caps text/plain

WARNING: erroneous pipeline: could not link fdsrc0 to txt, txt can't handle caps text/plain

 

 

No caps at all:

 

tail -f /home/pi/test.txt | /opt/gst/bin/gst-launch-1.0 fdsrc fd=0 ! txt. videotestsrc ! videoconvert ! decodebin ! textoverlay name=txt !  omxh264enc target-bitrate=800000 control-rate=3 ! tcpserversink host=0.0.0.0 port=9000

 

Results in:

 

Pipeline is PREROLLING ...

WARNING: from element /GstPipeline:pipeline0/GstTextOverlay:txt: Could not multiplex stream.

Additional debug info:

gstbasetextoverlay.c(2449): gst_base_text_overlay_video_event (): /GstPipeline:pipeline0/GstTextOverlay:txt:

received non-TIME newsegment event on video input

WARNING: from element /GstPipeline:pipeline0/GstDecodeBin:decodebin0: Delayed linking failed.

Additional debug info:

./grammar.y(510): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstDecodeBin:decodebin0:

failed delayed linking some pad of GstDecodeBin named decodebin0 to some pad of GstTextOverlay named txt

ERROR: from element /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0: Internal data stream error.

Additional debug info:

gstbasesrc.c(2951): gst_base_src_loop (): /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0:

streaming stopped, reason not-linked (-1)

ERROR: pipeline doesn't want to preroll.

 

 

There is some information here (regarding the older version of gst-launch): 

 

And that links to this bug that was resolved (again, old gst-launch): 

 

 

I've seen a couple examples which used the "text/plain" caps.

 

I'm certainly open to cracking open the Python lib and giving it a shot.  I would need to read up on it a bit and I'm not familiar with the appsrc, either, but that's something else I'm open to. I have done very basic stuff with the Python libs but nothing too fancy or dynamic (basic pipelines, no more complex than I would get from gst-launch-1.0).

 

What would you recommend?  Is there an example or resource you could point me towards?

 

Thank you for your help

 

 

On Sun, Feb 26, 2017 at 2:46 PM, Nicolas Dufresne <[hidden email]> wrote:

Le dimanche 26 février 2017 à 06:18 -0800, Adam Plocher a écrit :


> Hello, I apologize if I'm posting this in the wrong place. I've
> previously asked this on stackoverflow and never got a response: http
> ://stackoverflow.com/questions/42128804/polling-a-text-file-and-
> overlaying-the-result-in-gstreamer
>
> I have a Raspberry Pi with a camera and I'm live streaming that back
> to another unit (it's for a baby monitor).  On the same Pi, I have a
> temperature sensor that is dumping the current temp to a file every 5
> seconds.
>
> My question: Is it possible to somehow poll that txt file and update
> a text-overlay on the live stream based on the current contents of
> that file?

filsesrc does not have this feature unfortunatly. I believe using
fdsrc, you could:

  tail -f text.txt | gst-launch-1.0 fdsrc ! ...

Let me know if that is a good work-around. If you are writing an app,
this can be done with a pipe, or if you prefer, with appsrc.

>
> I've tried using a filesrc and subparse, and it will grab it
> initially if I format the input text file properly, but it doesn't
> seem to update itself:
>
> gst-launch-1.0 -v \
>     filesrc location=/home/pi/temp.txt ! subparse ! txt. rpicamsrc
> awb-mode=0 awb-gain-red=1 awb-gain-blue=2 rotation=0 bitrate=820000
> preview=false brightness=67 contrast=30 sharpness=40 \
>     ! video/x-h264,width=800,height=480,framerate=10/1 \
>     ! h264parse ! decodebin ! videoconvert ! clockoverlay shaded-
> background=true draw-shadow=true font-desc="Nimbus Mono" \
>     ! textoverlay name=txt shaded-background=yes \
>     ! omxh264enc control-rate=3 target-bitrate=850000 \
>     ! tcpserversink host=0.0.0.0 port=5555 sync=true
>
> The input file looks like this:
> 1
> 00:00:00,000 --> 99:59:59,000
> 69 degrees
> Thank you!
> _______________________________________________
> 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

 

_______________________________________________
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: Dynamic text-overlay on live-stream using gst-launch-1.0

Adam Plocher
In reply to this post by filnet

Thank you Philippe,

 

I’ve tried it and now I’m getting a new message:

 

tail -f /home/pi/test.txt | /opt/gst/bin/gst-launch-1.0 fdsrc fd=0 ! "text/x-raw, format=utf8" ! txt. videotestsrc ! videoconvert ! decodebin ! textoverlay name=txt ! omxh264enc target-bitrate=800000 control-rate=3 ! tcpserversink host=0.0.0.0 port=9000

 

Setting pipeline to PAUSED ...

Pipeline is PREROLLING ...

WARNING: from element /GstPipeline:pipeline0/GstTextOverlay:txt: Could not multiplex stream.

Additional debug info:

gstbasetextoverlay.c(2340): gst_base_text_overlay_text_event (): /GstPipeline:pipeline0/GstTextOverlay:txt:

received non-TIME newsegment event on text input

Pipeline is PREROLLED ...

Setting pipeline to PLAYING ...

New clock: GstSystemClock

 

Any idea what that means?

 

Thanks!

 

From: gstreamer-devel [mailto:[hidden email]] On Behalf Of philippe renon
Sent: Monday, February 27, 2017 8:03 AM
To: Discussion of the development of and with GStreamer <[hidden email]>
Subject: Re: Dynamic text-overlay on live-stream using gst-launch-1.0

 

textoverlay accepts caps defined as:
text/x-raw, format=(string){ pango-markup, utf8 }

may be you need to set caps to "text/x-raw, format=utf8" or something along those line.

 

Le Lundi 27 février 2017 16h34, Nicolas Dufresne <[hidden email]> a écrit :

 

Le lundi 27 février 2017 à 07:05 -0800, Adam Plocher a écrit :

Nicolas, thank you for your response.  fdsrc seems like it would be a good solution, but I'm having issues getting it to work.

 

It seems like I need to specify the caps after the fdsrc, otherwise it fails in other ways.  e.g.

 

 

Specifying text/x-raw:

 

tail -f /home/pi/test.txt | /opt/gst/bin/gst-launch-1.0 fdsrc fd=0 ! "text/x-raw" ! txt. videotestsrc ! videoconvert ! decodebin ! textoverlay name=txt ! omxh264enc target-bitrate=800000 control-rate=3 ! tcpserversink host=0.0.0.0 port=9000

 

I think you forgot to keep subparse element.

 

 

Results in:

 

Pipeline is PREROLLING ...

ERROR: from element /GstPipeline:pipeline0/GstCapsFilter:capsfilter0: Filter caps do not completely specify the output format

Additional debug info:

gstcapsfilter.c(455): gst_capsfilter_prepare_buf (): /GstPipeline:pipeline0/GstCapsFilter:capsfilter0:

Output caps are unfixed: text/x-raw, format=(string){ pango-markup, utf8 }

ERROR: pipeline doesn't want to preroll.

 

 

Specifying text/plain:

 

tail -f /home/pi/test.txt | /opt/gst/bin/gst-launch-1.0 fdsrc fd=0 ! "text/plain" ! txt. videotestsrc ! videoconvert ! decodebin ! textoverlay name=txt ! omxh264enc target-bitrate=800000 control-rate=3 ! tcpserversink host=0.0.0.0 port=9000

 

Results in:

 

0:00:00.501757360  4549  0x1e085c0 ERROR           GST_PIPELINE grammar.y:714:gst_parse_perform_link: could not link fdsrc0 to txt, txt can't handle caps text/plain

WARNING: erroneous pipeline: could not link fdsrc0 to txt, txt can't handle caps text/plain

 

 

No caps at all:

 

tail -f /home/pi/test.txt | /opt/gst/bin/gst-launch-1.0 fdsrc fd=0 ! txt. videotestsrc ! videoconvert ! decodebin ! textoverlay name=txt !  omxh264enc target-bitrate=800000 control-rate=3 ! tcpserversink host=0.0.0.0 port=9000

 

Results in:

 

Pipeline is PREROLLING ...

WARNING: from element /GstPipeline:pipeline0/GstTextOverlay:txt: Could not multiplex stream.

Additional debug info:

gstbasetextoverlay.c(2449): gst_base_text_overlay_video_event (): /GstPipeline:pipeline0/GstTextOverlay:txt:

received non-TIME newsegment event on video input

WARNING: from element /GstPipeline:pipeline0/GstDecodeBin:decodebin0: Delayed linking failed.

Additional debug info:

./grammar.y(510): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstDecodeBin:decodebin0:

failed delayed linking some pad of GstDecodeBin named decodebin0 to some pad of GstTextOverlay named txt

ERROR: from element /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0: Internal data stream error.

Additional debug info:

gstbasesrc.c(2951): gst_base_src_loop (): /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0:

streaming stopped, reason not-linked (-1)

ERROR: pipeline doesn't want to preroll.

 

 

There is some information here (regarding the older version of gst-launch): 

 

And that links to this bug that was resolved (again, old gst-launch): 

 

 

I've seen a couple examples which used the "text/plain" caps.

 

I'm certainly open to cracking open the Python lib and giving it a shot.  I would need to read up on it a bit and I'm not familiar with the appsrc, either, but that's something else I'm open to. I have done very basic stuff with the Python libs but nothing too fancy or dynamic (basic pipelines, no more complex than I would get from gst-launch-1.0).

 

What would you recommend?  Is there an example or resource you could point me towards?

 

Thank you for your help

 

 

On Sun, Feb 26, 2017 at 2:46 PM, Nicolas Dufresne <[hidden email]> wrote:

Le dimanche 26 février 2017 à 06:18 -0800, Adam Plocher a écrit :
> Hello, I apologize if I'm posting this in the wrong place. I've
> previously asked this on stackoverflow and never got a response: http
> ://stackoverflow.com/ questions/42128804/polling-a- text-file-and-
> overlaying-the-result-in- gstreamer
>
> I have a Raspberry Pi with a camera and I'm live streaming that back
> to another unit (it's for a baby monitor).  On the same Pi, I have a
> temperature sensor that is dumping the current temp to a file every 5
> seconds.
>
> My question: Is it possible to somehow poll that txt file and update
> a text-overlay on the live stream based on the current contents of
> that file?

filsesrc does not have this feature unfortunatly. I believe using
fdsrc, you could:

  tail -f text.txt | gst-launch-1.0 fdsrc ! ...

Let me know if that is a good work-around. If you are writing an app,
this can be done with a pipe, or if you prefer, with appsrc.

>
> I've tried using a filesrc and subparse, and it will grab it
> initially if I format the input text file properly, but it doesn't
> seem to update itself:
>
> gst-launch-1.0 -v \
>     filesrc location=/home/pi/temp.txt ! subparse ! txt. rpicamsrc
> awb-mode=0 awb-gain-red=1 awb-gain-blue=2 rotation=0 bitrate=820000
> preview=false brightness=67 contrast=30 sharpness=40 \
>     ! video/x-h264,width=800,height= 480,framerate=10/1 \
>     ! h264parse ! decodebin ! videoconvert ! clockoverlay shaded-
> background=true draw-shadow=true font-desc="Nimbus Mono" \
>     ! textoverlay name=txt shaded-background=yes \
>     ! omxh264enc control-rate=3 target-bitrate=850000 \
>     ! tcpserversink host=0.0.0.0 port=5555 sync=true
>
> The input file looks like this:
> 1
> 00:00:00,000 --> 99:59:59,000
> 69 degrees
> Thank you!
> ______________________________ _________________
> 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

 

_______________________________________________
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

 


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

Re: Dynamic text-overlay on live-stream using gst-launch-1.0

Nicolas Dufresne-5
In reply to this post by Adam Plocher
Le lundi 27 février 2017 à 22:30 -0800, Adam Plocher a écrit :
> So I think these are my options:
> -          Is there another format or something that the subtitles
> can be written in?
> -          Or a way to cause newer sub-titles take precedence over
> older ones?
> -          Or am I going to need to keep track of the play-time from
> my secondary process and regularly append accurate times to the
> file/stdout?

At this stage, you next step is to write some C or Python code, and use
appsrc. This way you can create text buffers with generated timestamp
(with or without subparse).

regards,
Nicolas
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (188 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic text-overlay on live-stream using gst-launch-1.0

filnet
Did you try with udpsrc ? As per the doc it will timestamp captured buffers and so should not suffer from the issue you have with fdsrc.

"The udpsrc is always a live source. It does however not provide a GstClock, this is left for upstream elements such as an RTP session manager or demuxer (such as an MPEG demuxer). As with all live sources, the captured buffers will have their timestamp set to the current running time of the pipeline."


Le Dimanche 5 mars 2017 21h36, Nicolas Dufresne <[hidden email]> a écrit :


Le lundi 27 février 2017 à 22:30 -0800, Adam Plocher a écrit :
> So I think these are my options:
> -          Is there another format or something that the subtitles
> can be written in?
> -          Or a way to cause newer sub-titles take precedence over
> older ones?
> -          Or am I going to need to keep track of the play-time from
> my secondary process and regularly append accurate times to the
> file/stdout?

At this stage, you next step is to write some C or Python code, and use
appsrc. This way you can create text buffers with generated timestamp
(with or without subparse).

regards,

Nicolas

_______________________________________________
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