Hi Now I'm trying to play mp4 files After trying to play mp4 file to demuxing A stream error may occur. My code will let me know if there are any problems Ask advice. thank you! * error : GStreamer encountered a general stream error. um...Add to I want to make the final application is An application with the pipeline, such as an attached image Combine the mp4 file and one subtitle file is application. If wrong with respect to the structure, please advise. --------------------------------------------------------------------------------------------- #include <stdio.h> #include <stdlib.h> #include "gst/gst.h" #include <glib.h> #include <string.h> static gboolean bus_call(GstBus *bus, GstMessage *msg, void *data){ gchar *debug; GError *err; GMainLoop *loop = (GMainLoop*)data; switch (GST_MESSAGE_TYPE(msg)){ case GST_MESSAGE_APPLICATION: g_print("APP received on OBJ NAME %s\n",GST_OBJECT_NAME(msg->src)); break; case GST_MESSAGE_EOS: g_print("EOS received on OBJ NAME %s\n",GST_OBJECT_NAME(msg->src)); g_main_loop_quit (loop); break; case GST_MESSAGE_ERROR: gst_message_parse_error(msg, &err, &debug); g_free(debug); g_print("BUS CALL %s\n", err->message); g_error_free(err); g_main_loop_quit (loop); break; default: break; } return TRUE; } static void on_pad_added (GstElement *element,GstPad *pad,gpointer data){ GstPad *sinkpad; GstElement *decoder = (GstElement *) data; /* We can now link this pad with the vorbis-decoder sink pad */ g_print ("Dynamic pad created, linking demux/vqueue\n"); sinkpad = gst_element_get_static_pad (decoder, "sink"); gst_pad_link (pad, sinkpad); gst_object_unref (sinkpad); } int main(int argc, char* argv[]){ GMainLoop *loop; GstElement *pipeline, *vsource, *demux, *vqueue, *ssource, *muxer, *filesink; GstElement *vplay, *conv; //GstBin *recording; GstBus *bus; GstPad *srcpad, *sinkpad; guint bus_watch_id; gst_init (&argc, &argv); loop = g_main_loop_new (NULL, FALSE); //recording = GST_BIN(gst_bin_new("recording-bin")); pipeline = gst_pipeline_new("Live Recording"); vsource = gst_element_factory_make("filesrc","v-file-source"); demux = gst_element_factory_make("qtdemux","v-file-demux"); vqueue = gst_element_factory_make("queue2","v-file-queue"); vplay = gst_element_factory_make("autovideosink","v-file-play"); conv = gst_element_factory_make("videoconvert","converter"); /* ssource = gst_element_factory_make("filesrc","s-file-source"); muxer = gst_element_factory_make("qtmux","mp4-container"); filesink = gst_element_factory_make("filesink","up-sink"); */ if(!pipeline) g_print("no pipe\n"); if(!vsource) g_print("no video source\n"); if(!demux) g_print("no video demux\n"); if(!vqueue) g_print("no video queue\n"); if(!vplay) g_print("no video play\n"); if(!conv) g_print("no conv"); /*if(!ssource) g_print("no srt source"); if(!muxer) g_print("no mp4 muxer"); if(!filesink) g_print("no filesink");*/ g_object_set (G_OBJECT (vsource), "location", "./sample.mp4", NULL); 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),vsource,demux,vqueue,ssource,muxer,filesink); gst_bin_add_many(GST_BIN(pipeline),vsource,demux,vqueue, conv, vplay,NULL); if(!gst_element_link(vsource, demux)){ g_print("no link"); } if(!gst_element_link_many(vqueue, conv, vplay,NULL)){ g_print("no link many"); } g_print("now play\n"); g_signal_connect (demux, "pad-added", G_CALLBACK (on_pad_added), vqueue); /*srcpad= gst_element_get_static_pad (demux, "src%d"); sinkpad = gst_element_get_static_pad (vqueue, "sink"); gst_pad_link(srcpad,sinkpad); */ gst_element_set_state(pipeline, GST_STATE_PLAYING); g_main_loop_run(loop); gst_element_set_state (pipeline, GST_STATE_NULL); gst_object_unref(GST_OBJECT(pipeline)); g_source_remove(bus_watch_id); g_main_loop_unref(loop); return 0; } |
Free forum by Nabble | Edit this page |