How to stop and restart writing to a filesink (while the pipeline is alive).

Streit Eric eric at yojik.eu
Sun Sep 16 23:55:12 PDT 2012


Hi,

I had the same problem when I wrote my "recorder" 5 years ago and I
managed to have something working: the program was designed to record a
list of words/phrases and save them in a separate file (with encoding:
flac).

It was working, but not perfect: you can find a archive on
http://www.yojik.eu/ (YazikRecorder).

I'm writing a new version of it , essentially a new recording pipeline
with the help of :
http://cgit.freedesktop.org/gstreamer/gstreamer/tree/docs/design/part-dynamic.txt
 (which is not complete now on this website, but I have a copy of it).


It's written in python. (take a look at pipeline1 and pipeline2)

I don't understand why does'nt exit an element which take care of the
switching as the peipeline is running: it's a very common task
(switching effects, filesink ...)

Maybe a new element is allready there, and in this case, I would be
happy to know about it (with examples).

Hope this help,

Eric

ps: if you want, I can upload a copy of the text which disappeared on my
server.



Le 16/09/2012 21:11, Stefan Sauer a écrit :
> 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
> 
> 
> 
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> 



More information about the gstreamer-devel mailing list