[gst-devel] Saving audio source as multiple files

Jonathan Doherty doherty-j22 at ulster.ac.uk
Thu Aug 10 11:26:55 CEST 2006

I've been using Gstreamer 0.8 to record an audio stream to my hard drive
in sections of 15 seconds using the following code:

location = "/home/audio";
fileExt = ".ogg";
char filepath[100] = {0};
sprintf(filepath, "%s%d%s", location, fileNo, fileExt);
/*Create sink with new path.  Check if pipeline already exists, if so *
* remove */
if ( pipeline ) {
	gst_element_set_state (pipeline, GST_STATE_PAUSED);
	gst_element_set_state ( sink, GST_STATE_PAUSED);
	gst_element_set_state ( sink, GST_STATE_NULL);
	gst_object_unref (GST_OBJECT(pipeline));
/*re-initialise sink for new path... */
pipeline = gst_thread_new ("main_thread");
source = gst_element_factory_make ("gnomevfssrc", NULL);
sink = gst_element_factory_make ("filesink", NULL);

/* set filename property on the file source */
g_object_set (G_OBJECT (source), "location",
"http://XXX.XXX.XXX.XXX:8000/radio.ogg", NULL);
g_object_set (G_OBJECT (sink), "location", filepath, NULL);

/* link together...*/
gst_element_link (source, sink);
/* put all elements in bin. */
gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL);

/* set to playing */
gst_element_set_state (source, GST_STATE_READY);
gst_element_set_state (sink, GST_STATE_READY);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/*Increment file number...*/

My problem is that when I try this in Gstreamer 0.10 it doesn't work, I
end up with files with no data in them.  Gstreamer 0.10 uses a pipeline
instead of a thread and was wondering if this is the problem.  If there
is another way of doing this, I'd appreciate some help.


More information about the gstreamer-devel mailing list