[gst-devel] filesink content -> outputing in a file
Guilherme
grlongo.ireland at gmail.com
Tue Apr 28 00:42:24 CEST 2009
Thiago, I did it before and all I get is a cracked sound.
Pretty weird.
Have a look what I was doing before:
#include<gst/gst.h>
#include<glib.h>
static gboolean bus_call(GstBus *bus, GstMessage *msg, gpointer data);
int main(int argc, char *argv[])
{
GMainLoop *loop;
GstElement *pipeline, *source, *audioconvert, *wavenc, *filesink;
GstBus *bus;
gst_init(&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
/*creating elements*/
pipeline = gst_pipeline_new ("audio-player");
source = gst_element_factory_make ("audiotestsrc",
"file-source");
//audioconvert = gst_element_factory_make ("audioconvert",
"audio-conversor");
wavenc = gst_element_factory_make ("wavenc", "wave-enc");
filesink = gst_element_factory_make ("filesink",
"audio-output");
if (!pipeline || !source || !audioconvert|| !wavenc || !filesink) {
g_printerr ("One element could not be created. Exiting.\n");
return -1;
}
* g_object_set (G_OBJECT (filesink), "location", "foo.wav", NULL);*
/*set-up the pipeline*/
/*message handler*/
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
/*colocar todos elementos na pipeline*/
gst_bin_add_many (GST_BIN (pipeline), source, wavenc, filesink, NULL);
/*Linkar elementos*/
//gst_element_link ();
gst_element_link_many (source, wavenc, filesink, NULL);
//g_signal_connect (demuxer, "pad-added", G_CALLBACK (on_pad_added),
decoder);
/* set pipeline playing status */
g_print ("Running...\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/*iterate*/
g_print ("Recording\n");
g_main_loop_run (loop);
/* Out of the main loop, clean up nicely */
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Deleting pipeline\n");
gst_object_unref (GST_OBJECT (pipeline));
return 0;
}
static gboolean bus_call(GstBus *bus, GstMessage *msg, gpointer data) {
return TRUE;
}
More information about the gstreamer-devel
mailing list