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

Alexander Botero alex.botero at gmail.com
Tue Sep 18 06:55:26 PDT 2012


Hello,
Yes, your idea is pretty good. And it works very well with FLAC, WAV and
MP3 encoders.
The recorded files have correct length and the "silent" parts have gone
when replayed.

But AAC, OGG audio and SPX encoders (file formats) add the missing "silent"
bits when replayed, even the file has been cut correctly. I usually replay
my tests in Totem or RhythmBox.

This is exactly the same result I got with the VADer filter. (ref. my
previous posting).

The pipeline has this format:
pulsesrc device="xxx" ! level ! tee name=t ! queue ! fakesink t. ! queue !
valve ! encodebin ! filesink

Example1:
WAV encoder. This produces correct result.
gchar *pipeline_cmd = g_strdup("pulsesrc name=source"
                                 " ! level name=level"
                                 " ! tee name=t"
                                 " ! queue"
                                 " ! fakesink t."
                                 " ! queue"
                                 " ! valve name=valve"
                                 " ! audioconvert"
                                 " ! wavenc"
                                  " ! filesink name=filesink");


Example2:
OGG audio. Filesize is correct, but this adds the silent bits when
replayed.
gchar *pipeline_cmd = g_strdup("pulsesrc name=source"
                                 " ! level name=level"
                                 " ! tee name=t"
                                 " ! queue"
                                 " ! fakesink t."
                                 " ! queue"
                                 " ! valve name=valve"
                                 " ! audioconvert"
                                 " ! vorbisenc"
                                 " ! oggmux"
                                 " ! filesink name=filesink");

In the code I set:
g_object_set(G_OBJECT(valve), "drop", TRUE / FALSE , NULL);

*Conclusion:*
We have to understand that the pipeline and its elements have an internal
clock.
In some audio formats (like: OGG, AAC, and SPX) this clock overrides the
missing frames, thus adding silent bits to the media when replayed.

There are some functions that might adjust the clock.

gst_element_get_base_time(...) and gst_element_set_base_time(...)
gst_element_get_start_time(...) and gst_element_set_start_time(...)

Or:
GstEvent *segment = gst_event_new_new_segment(FALSE, 1.0, GST_FORMAT_TIME,
g_start_time,  g_end_time, g_start_time);
ret = gst_pad_send_event(sinkpad , segment);

But I do not know these methods well.

Anyway, it's been an interesting ride so far, and new comments are still
welcomed.
--------------------------

Tested formats from gconf-editor,  system -> gstreamer -> 0.10 -> audio ->
profiles:
AAC: audio/x-raw-int,rate=44100,channels=2 ! faac profile=2 ! ffmux_mp4
FLAC: audio/x-raw-int,rate=44100,channels=2 ! flacenc name=enc
OGG: audio/x-raw-float,rate=44100,channels=2 ! vorbisenc name=enc
quality=0.5 ! oggmux
MP3: audio/x-raw-int,rate=44100,channels=2 ! lamemp3enc name=enc target=0
quality=6 ! xingmux ! id3v2mux
WAV: audio/x-raw-int,rate=22050,channels=1 ! wavenc name=enc
SPX: audio/x-raw-int,rate=32000,channels=1 ! speexenc name=enc ! oggmux

Greetings
Alexander

On Sun, Sep 16, 2012 at 9:11 PM, Stefan Sauer <ensonic at hora-obscura.de>wrote:

>  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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20120918/2076dab8/attachment.html>


More information about the gstreamer-devel mailing list