How to stop and restart writing to a filesink (while the pipeline is alive).
Stefan Sauer
ensonic at hora-obscura.de
Sun Sep 16 12:11:59 PDT 2012
On 09/10/2012 07:48 PM, Alexander Botero wrote:
> Hello,
> I have a small audio recorder that uses Gstreamer.
> I would like the recorder to pause when the signal-level drops under a
> certain value, and re-start when the level rises again.
>
> I cannot simply set the pipeline or filesink to GST_STATE_PAUSED or
> NULL because my code needs to check the level-value all the time (so
> it can determine when to stop or re-start writing to a sink file).
> The pipeline must run all the time so the "message::element" message
> is generated and level_message_cb(...) is called continually.
>
> How can I stop (and re-start) writing to a filesink, while the
> pipeline is ticking and alive?
> I understand this can be difficult because container formats (like
> ogg) need to write bytes to previous blocks.
You could do something like this:
autoaudiosrc ! level ! tee name=t ! queue ! autoaudiosink t. ! queue !
valve ! encodebin ! filesink
when the level drops below a threshold, you close the valve and remember
the position. When the level gets above the threshold again, you open he
valve (and eventually push a newsegment event).
Stefan
>
> Here is my test-code, a small gtk-program:
> http://www.futuredesktop.org/tmp/test1.c
>
> I have tried to stop/start the filesink with various methods.
> Please see set_filesink1(...) and set_filesink2(...).
>
> For example, I tried to set the filesink to READY-state, then setting
> its location to NULL, and later back to "test1.ogg" But this is not
> allowed.
>
> Compile:
> gcc -Wall test1.c -o test1 $(pkg-config --cflags --libs gtk+-3.0
> gthread-2.0 gstreamer-0.10)
>
> Run:
> ./test1
>
> The recorder is open source.
>
> Kindly
> Alexander
>
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20120916/789ce5f8/attachment.html>
More information about the gstreamer-devel
mailing list