LachoTomov
LachoTomov

Reputation: 3689

Pausing a gstreamer thread made with tee

I have a gstreamer pipeline that takes video from the webcam and splits it into two threads:
1) use appsink so I can programmatically edit the captured frames
2) saves the video to a file

The pipeline looks like this:

gst-launch-1.0 v4l2src device=/dev/video0 \
! tee name=t ! queue ! videoconvert ! videoscale ! appsink name=sink caps="video/x-raw,format=RGB,width=800,framerate=15/1" t. \
! queue ! video/x-raw,width=800,framerate=15/1 ! jpegenc ! avimux ! filesink location=/tmp/output.avi

I'm using this inside a C++ app.

My problem is that in most of the time I don't need the two threads running simultaneously, but only one of them. And in rare cases - need both.
So I need some way to temporarily pause/stop either the appsink or the video saving - in order to save CPU.

The way I do it now is to destroy the pipeline and recreate it again with only one thread when needed, but that seems quite ugly.

I've been looking for a better solution, but no luck so far - is there any way to do that?

Thanks in advance!

Upvotes: 2

Views: 2102

Answers (1)

mpr
mpr

Reputation: 3378

An easier way to approach this may be to use a valve element. It has a drop property that you can set to true or false. Put it right after the queue on the tee.

http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer-plugins/html/gstreamer-plugins-valve.html

EDIT: This doesn't work. Some more details are present in this post on the GStreamer mailing list:

http://gstreamer-devel.966125.n4.nabble.com/How-to-Stop-start-recording-using-Valve-element-td4661728.html

Upvotes: 2

Related Questions