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

Alexander Botero alex.botero at gmail.com
Wed Sep 19 10:03:00 PDT 2012


Stefan, I took your "encodebin" very literally and made some tests with it.

I learned that it's possible to create a media (encoding) profile during
runtime.
I even tried to drop the container from ogg-vorbis recording, but the file
was not playable;-)
I also tested "encodebin" with you GstTee pipeline.

I haven't managed to adjust the internal clock of AAC, OGG Vorbis and SPX
formats.
They still "remember" the slient parts. But these tests have been very
interesting to do.

Current solution / eu resolvi por esta solução:
I have decided to use the VADer element i our (GPL'ed) audio-recorder
because it has a very good algorithm for audio detection and noise
filtering.
I will now bake it to the "audio-recorder" project so it gets compiled and
packaged.

The "silent" detection in the recorder will become much simpler. The
actual, old version creates two (2) long pipelines; one for the "silent"
detection and second (similar) pipeline for recording. This is awful waste
of resources.

But of course, the new recorder must live with the above problem with AAC,
OGG and SPX formats. That's life!
------------

static GstElement *create_pipeline() {
    GstElement *pipeline = gst_pipeline_new("a simple recorder");

    GstElement *src = gst_element_factory_make("pulsesrc", "source");
    g_object_set(G_OBJECT(src), "device", "alsa_input.usb-Creative_....",
NULL);

    GstElement *filesink = gst_element_factory_make("filesink", "filesink");
    g_object_set(G_OBJECT(filesink), "location", "test.xxx", NULL);

    GstElement *queue = gst_element_factory_make("queue", NULL);
    GstElement *ebin = gst_element_factory_make("encodebin", NULL);

    GstEncodingProfile *prof = create_ogg_vorbis_profile(1, NULL);
    g_object_set (ebin, "profile", prof, NULL);
    gst_encoding_profile_unref (prof);

    gst_bin_add_many(GST_BIN(pipeline), src, queue, ebin, filesink, NULL);

    if (!gst_element_link_many(src, queue, ebin, filesink, NULL)) {
       g_printerr("Cannot link many.\n");
    }

    GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
    gst_bus_add_signal_watch(bus);
    g_signal_connect(bus, "message::element", G_CALLBACK(level_message_cb),
NULL);
    gst_object_unref(bus);
}

static GstEncodingProfile *create_ogg_vorbis_profile (guint presence, gchar
* preset) {
    // I copied this from gstreamer's test-module. It seems to be very easy
to create new profiles.
    GstEncodingContainerProfile *cprof;
    GstCaps *ogg, *vorbis;

    ogg = gst_caps_new_simple ("application/ogg", NULL);
    cprof = gst_encoding_container_profile_new ((gchar *) "oggprofile",
NULL, ogg, NULL);
    gst_caps_unref (ogg);

    vorbis = gst_caps_new_simple ("audio/x-vorbis", NULL);
    gst_encoding_container_profile_add_profile (cprof, (GstEncodingProfile
*) gst_encoding_audio_profile_new (vorbis, preset, NULL, presence));
    gst_caps_unref (vorbis);

    // vorbisenc:
    // audio/x-raw-float, rate=(int)[ 1, 200000 ], channels=(int)[ 1, 255
], endianness=(int)1234, width=(int)32
    //
    // caps = gst_caps_new_simple("audio/x-raw-float",
    //                "rate",G_TYPE_INT, 8000,
    //                "channels" ,G_TYPE_INT, (gint)1,
    //                "endianness",G_TYPE_INT,(gint)1234,
    //                "width" ,G_TYPE_INT, (gint)8, NULL);

    return (GstEncodingProfile *)cprof;
}

Kindly
  Osmo Antero


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/20120919/b6456d72/attachment.html>


More information about the gstreamer-devel mailing list