Crossfade - Resource not found message at runtime

Nicolai Hess nicolaihess at web.de
Wed Sep 7 13:42:19 PDT 2011


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 <guerra.rossana at gmail.com>

> 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 <amartin at vicomtech.org>
>
>> 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 <guerra.rossana at gmail.com>
>>
>>> 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
>>> gstreamer-devel at lists.freedesktop.org
>>> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>>>
>>>
>>
>>
>> --
>>
>> Ángel Martín Navas
>> Investigador / Researcher
>> Televisión Digital y Servicios Multimedia / Digital TV & Multimedia Services
>>
>> Vicomtech - Visual Interaction Communication Technologies
>>
>>
>> Mikeletegi Pasealekua, 57 - Parque Tecnológico
>> 20009 Donostia - San Sebastián - Spain
>> Tel: +[34] 943 30 92 30
>> Fax: +[34] 943 30 93 93
>>
>> e-mail: amartin at vicomtech.org
>> www.vicomtech.org
>>
>> *** member of IK4 Research Alliance ****
>> www.ik4.es
>> *** member of GraphicsMedia.net ****
>>
>> www.graphicsmedia.net
>>
>>
>>
>> -----------------------------------------------------
>> Vicomtech is an ISO 9001:2000 certified institute
>> -----------------------------------------------------
>>
>>
>> Este mensaje se dirige exclusivamente a su destinatario.
>> La información incluida en el presente correo es confidencial sometida a
>> secreto profesional, especialmente en lo que respecta a los datos de
>> carácter personal, cuya divulgación está prohibida, en virtud de la
>>
>>
>> legislación vigente. Si usted no es el destinatario legítimo y lo ha
>> recibido por error o tiene conocimiento del mismo por cualquier motivo,
>> le rogamos que nos lo comunique por este medio y proceda a destruirlo o
>>
>>
>> borrarlo. En todo caso abstengase de utilizar, reproducir, alterar,
>> archivar o comunicar a terceros el presente mensaje así como los ficheros
>> anexos, todo ello bajo pena de incurrir en responsabilidades legales.
>>
>>
>> Cualquier opinión contenida en este correo es exclusiva de su autor y no
>> representa necesariamente la opinión de ASOCIACIÓN CENTRO DE TECNOLOGÍAS
>> DE INTERACCIÓN VISUAL Y COMUNICACIONES VICOMTECH (en adelante Vicomtech-IK4)
>>
>>
>> El emisor no garantiza la integridad, rapidez o seguridad del presente correo,
>> ni se responsabiliza de posibles perjuicios derivados de la captura,
>> incorporaciones de virus o cualesquiera otras manipulaciones efectuadas por terceros.
>>
>>
>> Con motivo de la entrada en vigor de la Ley 34/2002, de 11 de julio, de
>> Servicios de la Sociedad de la Información y de Comercio Electrónico, le
>> informamos que pueden revocar en cualquier momento, de forma sencilla y gratuita,
>>
>>
>> el consentimiento para la recepción de mensajes de vicomtech.org en info.lopd at vicomtech.org.
>>
>>
>>
>> _______________________________________________
>> gstreamer-devel mailing list
>> gstreamer-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>>
>>
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20110907/2ca9a63b/attachment-0001.htm>


More information about the gstreamer-devel mailing list