Hi all, I am totally new with GSteamer, so sorry for the lots of mistakes I have. I am trying to do the example of this link in C/C++ http://notes.brooks.nu/gstreamer-video-crossfade-example/
It's about crossfade. I doing it with .AVI files. At runtime I got the Resource not found error. Another examples, like a playbin, work properly with .AVI's, so I don't think is a codec issue. The video files are passing as arguments (uri format). Thanks in advance. ///////////////////////// Heres the code #include <gst.h> #include <controller/gstcontroller.h> #include <iostream> using namespace std; // Error handler static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data) { GMainLoop *loop = (GMainLoop *) data; switch (GST_MESSAGE_TYPE (msg)) { case GST_MESSAGE_EOS: g_print ("Final de stream\n"); g_main_loop_quit (loop); break; case GST_MESSAGE_ERROR: { gchar *debug; GError *error; gst_message_parse_error (msg, &error, &debug); g_free (debug); g_printerr ("Error: %s\n", error->message); g_error_free (error); g_main_loop_quit (loop); break; } default: break; } return TRUE; } static void on_pad_added (GstElement *element, GstPad *pad, gpointer data) { GstPad *sinkpad; GstElement * queue = (GstElement *) data; /* We can now link this pad with the vorbis-decoder sink pad */ g_print ("Dynamic pad created, linking demuxer/decoder\n"); sinkpad = gst_element_get_static_pad (queue, "sink"); gst_pad_link (pad, sinkpad); gst_object_unref (sinkpad); } GstElement * getBin(const gchar * nomBin, GstElement * &alfa1, GstElement *&alfa2, GstElement * &color) { GstElement * bin = gst_bin_new(nomBin); if (!bin) { g_printerr ("No se pudo crear el bin. Saliendo\n"); return NULL; } alfa1 = gst_element_factory_make ("alpha","alfa1"); alfa2 = gst_element_factory_make ("alpha","alfa2"); color = gst_element_factory_make ("ffmpegcolorspace", "color"); GstElement * mixer = gst_element_factory_make("videomixer", "mixer"); if ((!alfa1) || (!alfa2) || (!color) || (!mixer)) { g_printerr ("Alguno de los elementos del Bin no pudo ser creado. Saliendo\n"); return NULL; } // Anexamos al bin gst_bin_add_many(GST_BIN (bin),alfa1,alfa2,mixer,color,NULL); // Enlazamos elementos gst_element_link (alfa1, mixer); gst_element_link (alfa2, mixer); gst_element_link (mixer,color); return bin; } void getAndSetController(GstElement * alfa2, gdouble duracion) { GstController * ctrl = NULL; if (!(ctrl = gst_controller_new (G_OBJECT (alfa2), "alpha",NULL))) { GST_WARNING ("No puede controlar el elemento fuente\n"); return; } // Todo valor GValue debe inicializarse en 0 GValue val_double = { 0, }; g_value_init (&val_double, G_TYPE_DOUBLE); // Seteo los valores de control del alfa2 GstInterpolationControlSource * csource = gst_interpolation_control_source_new(); gst_controller_set_control_source (ctrl, "alpha", GST_CONTROL_SOURCE (csource)); gst_interpolation_control_source_set_interpolation_mode(csource,GST_INTERPOLATE_LINEAR); g_value_set_double(&val_double, 0.0); gst_interpolation_control_source_set(csource,(0* GST_MSECOND),&val_double); g_value_set_double (&val_double, duracion); gst_interpolation_control_source_set(csource,(1 * GST_MSECOND),&val_double); g_object_unref (csource); } void addGhostPadsToBin(GstElement *alfa1, GstElement * alfa2, GstElement * color, GstElement* bin) { /* add ghostpad */ GstPad * pad1 = gst_element_get_static_pad (alfa1, "sink"); gst_element_add_pad(bin, gst_ghost_pad_new("alfasink1", pad1)); gst_object_unref (GST_OBJECT (pad1)); GstPad * pad2 = gst_element_get_static_pad (alfa2, "sink"); gst_element_add_pad(bin, gst_ghost_pad_new("alfasink2", pad2)); gst_object_unref(GST_OBJECT(pad2)); GstPad * pad3 = gst_element_get_static_pad (color, "src"); gst_element_add_pad(bin, gst_ghost_pad_new("colorsrc", pad3)); gst_object_unref(GST_OBJECT(pad3)); } void crossFade(gdouble duracion, GstElement * & bin) { // devuelve el bin GstElement * alfa1, *alfa2, *color; alfa1 = 0; alfa2 = 0; color = 0; bin = getBin("bin",alfa1, alfa2,color); // Crea el bin y los elementos getAndSetController(alfa2,duracion); addGhostPadsToBin(alfa1, alfa2, color, bin); } GstElement * getSetPipeline(gchar *argv[]) { gint dur1 = 9000; // duration (in ms) to play of first clip gint dur2 = 8000; // duration (in ms) to play of second clip gint dur_crossfade = 500; //number of milliseconds to crossfade for GstElement *comp = 0; GstElement *pipeline, *video1, *video2, *op, *bin, *queue, *sink; //we play two clips serially with a crossfade between them // using the gnonlin gnlcomposition element. if ((comp = gst_element_factory_make("gnlcomposition", "mycomposition")) == NULL) { printf ("\n Fallo al crear gnlcomposition \n"); return NULL; } // setup first clip if ((video1 = gst_element_factory_make("gnlfilesource", "video1")) == NULL) { printf ("\n Falló la creacion del gnlfilesource \n"); return NULL; } if (gst_bin_add (GST_BIN (comp), video1) == FALSE) { printf ("\n No pudo agregar video1 a comp \n"); return NULL; } g_object_set (video1, "location", argv[1], NULL); g_object_set (video1, "start", 0 * GST_MSECOND, NULL); g_object_set (video1, "duration", dur1 * GST_MSECOND, NULL); g_object_set (video1, "media-start", 0* GST_MSECOND, NULL); g_object_set (video1, "media-duration", dur1 * GST_MSECOND, NULL); g_object_set (video1, "priority", 1,NULL); if ((video2 = gst_element_factory_make("gnlfilesource", "video2")) == NULL) { printf ("\n Falló la creacion del gnlfilesource \n"); return NULL; } if (gst_bin_add (GST_BIN (comp), video2) == FALSE) { printf ("\n No pudo agregar video2 a comp \n"); return NULL; } // setup second clip g_object_set (video2, "location", argv[2], NULL); g_object_set (video2, "start", (dur1-dur_crossfade) * GST_MSECOND, NULL); g_object_set (video2, "duration", dur2 * GST_MSECOND, NULL); g_object_set (video2, "media-start", 0 * GST_MSECOND, NULL); g_object_set (video2, "media-duration", dur2 * GST_MSECOND, NULL); g_object_set (video2, "priority", 2,NULL); // setup the crossfade op = gst_element_factory_make("gnloperation", "op"); crossFade(dur_crossfade, bin); if (gst_bin_add (GST_BIN (op), bin) == FALSE) { printf ("\n No pudo agregar el bin a la gnloperacion op \n"); return NULL; } g_object_set (op,"start", (dur1-dur_crossfade) * GST_MSECOND,NULL); g_object_set (op,"duration", dur_crossfade * GST_MSECOND,NULL); g_object_set (op,"media-start", 0 * GST_MSECOND,NULL); g_object_set(op,"media-duration", dur_crossfade * GST_MSECOND,NULL); g_object_set(op,"priority",0,NULL); if (gst_bin_add (GST_BIN (comp), op) == FALSE) { printf ("\n No pudo agregar la gnloperacion a la gnlcomposition \n"); return NULL; } // setup the backend viewer queue = gst_element_factory_make("queue", "queue"); sink = gst_element_factory_make("autovideosink", "sink"); pipeline = gst_pipeline_new ("video-player"); /* Agrego elementos al pipeline */ gst_bin_add_many (GST_BIN (pipeline),comp, queue, sink, NULL); g_signal_connect (comp, "pad-added", G_CALLBACK (on_pad_added), queue); gst_element_link (queue, sink); cout << "creó pipeline!!!" << endl; return pipeline; } void startPlay(GstElement * pip) { /* Set the pipeline to "playing" state*/ cout << "antes del PLAY" << endl; gst_element_set_state (pip, GST_STATE_PLAYING); cout << "dp del PLAY" << endl; } int main(gint argc, gchar *argv[]) { GMainLoop *loop = NULL; /* init GStreamer */ gst_init (&argc, &argv); gst_controller_init (&argc, &argv); loop = g_main_loop_new (NULL, FALSE); /* make sure we have a URI */ if (argc != 3) { g_print ("Uso: %s <URI1> <URI2>\n", argv[0]); return -1; } GstElement * play = getSetPipeline(argv); cout << "creo pipeline" << endl; GstBus *bus2 = gst_pipeline_get_bus (GST_PIPELINE (play)); gst_bus_add_watch (bus2, bus_call, loop); gst_object_unref (bus2); cout << "start play" << endl; startPlay(play); /* now run */ g_main_loop_run (loop); /* also clean up */ gst_element_set_state (play, GST_STATE_NULL); gst_object_unref (GST_OBJECT (play)); return 0; } _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Dear Rossana,
I think that this kind of error message is obtained when the video resource is not found so check the file path to the files and be sure that the paths are right in the location assignment of each gnlfilesource. Moreover, You have a bug in the getAndSetController concerning the duration of the transition: g_value_set_double (&val_double, 1.0); gst_interpolation_control_source_set(csource,(duracion * GST_MSECOND),&val_double); Best, Angel 2011/9/7 Rossana Guerra <[hidden email]> Hi all, I am totally new with GSteamer, so sorry for the lots of mistakes I have. I am trying to do the example of this link in C/C++ http://notes.brooks.nu/gstreamer-video-crossfade-example/ -- Ángel Martín Navas _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Hi Angel, the path is correct. In fact I use the same path to another example.
Can you please tell me what kind of bug is? I can't realize. Thanks for your response 2011/9/7 Angel Martin <[hidden email]> Dear Rossana, _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Hi Rossane,
your code is working for me. Remember to use an URI for your input file arguments, example: nameofyourprogram file://<path_to_file1> file://<path_to_file2>
2011/9/7 Rossana Guerra <[hidden email]> Hi Angel, the path is correct. In fact I use the same path to another example. _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Hi Nicolai, does the crossfade work?.
Actually this is the syntax of the command (from console) ./crossfade file:///video1.avi file:///video2.avi crossfade : name of the programm I intended the uri format in several ways (according to URI specification), though noneone works, the same error. "Resource not found", file:///video1.avi file://video1.avi file:/video1.avi In the last 2 format the message says, resource for reading not found. Thanks for your help Rossana
2011/9/7 Nicolai Hess <[hidden email]> Hi Rossane, _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
you need the full path of your video files, for example
file:///home/nicolai/video1.avi 2011/9/7 Rossana Guerra <[hidden email]> Hi Nicolai, does the crossfade work?. _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |