Gstreamer Application
Giritharan
girisugu2 at gmail.com
Sun May 17 05:36:23 PDT 2015
Hi everyone,
i put my gstreamer c application main file.This is my working gstreamer
command is --*gst-launch mfw_v4lsrc capture-mode=1 fps-n=30 ! vpuenc
codec=0 ! queue ! mux. alsasrc ! 'audio/x-raw-int,rate=48000,channels=2' !
mfw_mp3encoder ! queue ! mux. avimux name=mux ! filesink
location=test_avi_cmd_ch1.avi sync=false*.
i wrote C application for this.while manually giving the gstreamer command
it captures video along with audio.But while run the following C
application,it captures only video.No audio.So please help me to capture
video along with audio for the following gstreamer application
*int
main (int argc,
char *argv[])
{
GMainLoop *loop;
GstElement *pipeline,*video_source, *video_encoder,
*video_queue,*audio_source,*audio_encoder,*audio_queue,*audio_muxer, *sink,
*filter;
//GstElement *pipeline, *source, *encoder, *sink;
GstBus *bus;
guint bus_watch_id;
//GstCaps *caps = gst_caps_new_empty();
gst_init (&argc, &argv);
GstCaps *audio_caps;
loop = g_main_loop_new (NULL, FALSE);
if(argc !=2)
{
g_printerr ("Usage: %s <Ogg/Vorbis filename>\n", argv[0]);
return -1;
}
/* Pipeline create */
pipeline = gst_pipeline_new("pipeline");
/*video source */
video_source = gst_element_factory_make("mfw_v4lsrc", "video_source");
/*codec encoder */
video_encoder = gst_element_factory_make("vpuenc", "video_encoder");
/*queue for video */
video_queue = gst_element_factory_make("queue", "video_queue");
/*audio source */
audio_source = gst_element_factory_make("alsasrc","audio_source");
filter = gst_element_factory_make("capsfilter", "filter");
/*audio encoder */
audio_encoder = gst_element_factory_make("mfw_mp3encoder",
"audio_encoder");
/*audio queue */
audio_queue = gst_element_factory_make("queue", "audio_queue");
/*muxer*/
audio_muxer = gst_element_factory_make("avimux","audio_muxer");
sink = gst_element_factory_make("filesink", "sink");
g_object_set (G_OBJECT (sink), "location",argv[1], NULL);
g_object_set(G_OBJECT (sink),"sync",FALSE,NULL);
audio_caps = gst_caps_new_simple("audio/x-raw-int",
"rate", G_TYPE_INT,44100,
"channels",G_TYPE_INT,1,
NULL);
g_object_set (G_OBJECT (filter), "caps", audio_caps, NULL);
g_object_set (G_OBJECT (video_source), "capture-mode", 1, NULL);
g_object_set (G_OBJECT (video_source), "fps-n", 30, NULL);
g_object_set (G_OBJECT (video_encoder),"codec", 0 , NULL);
g_object_set (G_OBJECT (sink), "location",argv[1], NULL);
g_object_set(G_OBJECT (sink),"sync",FALSE,NULL);
if(!pipeline || !video_source || !video_encoder || !video_queue
|| !audio_source || !audio_encoder || !audio_muxer
|| !filter || !sink) {gst-launch mfw_v4lsrc capture-mode=1 fps-n=30 !
vpuenc codec=0 ! queue ! mux. alsasrc !
'audio/x-raw-int,rate=48000,channels=2' ! mfw_mp3encoder ! queue ! mux.
avimux name=mux ! filesink location=test_avi_cmd_ch1.avi sync=false
g_printerr ("One element could not be created. Exiting.\n");
return -1;
}
printf("Creating watcher bus ID
*************************************************************************************************************\n");
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
gst_bin_add_many(GST_BIN (pipeline), video_source, video_encoder,
video_queue,audio_source,audio_encoder,audio_queue,audio_muxer,sink,filter,
NULL);
gst_element_link_many
(video_source,video_encoder,video_queue,audio_muxer,NULL);
gst_element_link_many(audio_source,filter,audio_encoder,audio_queue,audio_muxer,NULL);
gst_element_link(audio_muxer,sink);
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
//printf("Sending SIGNAL to audio_muxer*********\n");
// g_signal_connect (video_source, "pad-added", G_CALLBACK
(on_pad_added),sink);
//printf("SIGNAL sent ********\n");
g_print ("Now playing: %s\n", argv[1]);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print ("Running...\n");
g_main_loop_run (loop);
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));
g_source_remove (bus_watch_id);
g_main_loop_unref (loop);
return 0;
*
--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Gstreamer-Application-tp4671886p4671893.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
More information about the gstreamer-devel
mailing list