Hi Angel, thanks again for your suggestion, I was suspecting something of what you sad. <div>Let's see if I understand. The video and operator variable are within a pipeline, bin, so I need to re create the same "artfact" or pipeline. <div>
Do I need to unref video or op referecne and then create and re -add them into the corresponding bin/pipeline?.</div><div>Or I delete the whole pipeline?</div><div>Anf if it is so, where?.</div><div><br></div><div>Thanks for your responde</div>
<div><br></div><div>Rossana</div><div><br></div><div><br></div><div><br><div class="gmail_quote">2011/9/28 Angel Martin <span dir="ltr"><<a href="mailto:amartin@vicomtech.org">amartin@vicomtech.org</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi again,<br><br>I think that the problem is that you should create a completely different GstElement for each video or operation for each transition.<br><br>You want 3 videos, so 3 gst_element_factory_make should appear.<br>
<br>I think that you are reusing the same variable for different multimedia objects. Moreover, it is important that the name associated to each GstElement shouldn't be repeated, specially for concurrent objects.<br><br>
Best,<br><font color="#888888"><br>Angel</font><div><div></div><div class="h5"><br><br><div class="gmail_quote">2011/9/27 Rossana Guerra <span dir="ltr"><<a href="mailto:guerra.rossana@gmail.com" target="_blank">guerra.rossana@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
Hi another thing I noticed is that it takes the last properties I set to video2.<br>I meant, I execute video2 twice with differents properties, first for those corresponding to argv[2], and the second to argv[1].<br>Whatever were the values at argv[2] it doesn't matter if argv[1] are the correct ones.<br>
<br>I mean this:<br><br>video1 <br>video2, argv[2] to play at x time<br>video2 argv[1] to play after video1<br>It skips argv[2], so it keeps with the las values set. So, how I do to play a playlist with crossfade?.<br><br>
I wish I were clear.<br><br>Thanks,<br><br>Ro<div><div></div><div><br><br><div class="gmail_quote">2011/9/26 Rossana Guerra <span dir="ltr"><<a href="mailto:guerra.rossana@gmail.com" target="_blank">guerra.rossana@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
Hi Angel, thanks for your suggest, I did what you suggested but it didn't work. It only play the 1st vido. So I put back the variables. In fact, I want to have a play list, so I need to calculate the next start/duration attribute (I need variables for that).<br>
As I said if I test with 2 videos it works fine, the problems is when a 3rd one comes to the scenario.<br><br>This is the situation. I want to play a playlist with crossfade between videos. The crossfade time is fixed: 500ms.<br>
The first video lasts 9000ms<br>The 2nd lasts 8000ms.<br>The 3rd lasts 9000ms.<br><br>2nd video, start duration: 9000 - 500 // video1 duration - crossfade duration<br>3rd video start duration: 9000 + 8000 - 2*500 // video1 duration + video 2 duration - 2 * crossfade duration<br>
<br>According some test I did, it has to do with starting time of both, operation and 3rd video.<br><br>Thanks and any suggestion is welcome.<br><br>Here's the problematic part (start and duration with fixed attributes, didn't work)<div>
<br>
<br>void playSigVideo(gchar *argv[], GstElement *& video2, gint dur1, gint dur2,GstElement *&op, GstElement *pip)<br>{<br> g_object_set (op,"start", (dur1 -dur_crossfade) * GST_MSECOND,NULL);<br> g_object_set (op,"duration", dur_crossfade * GST_MSECOND,NULL);<br>
g_object_set (op,"media-start", 0 * GST_MSECOND,NULL);<br> g_object_set(op,"media-duration", dur_crossfade * GST_MSECOND,NULL);<br> g_object_set(op,"priority",0,NULL);<br><br></div>
// Playing 2nd video<div><br>
g_object_set (video2, "location", argv[2], NULL);<br> g_object_set (video2,"uri",argv[2],NULL);<br> g_object_set (video2, "start", (dur1 -dur_crossfade) * GST_MSECOND, NULL);<br> g_object_set (video2, "duration", dur2 * GST_MSECOND, NULL);<br>
g_object_set (video2, "media-start", 0 * GST_MSECOND, NULL);<br> g_object_set (video2, "media-duration", dur2 * GST_MSECOND, NULL);<br> g_object_set (video2, "priority", 2,NULL);<br>
<br></div> g_object_set (op,"start", (dur1 + dur2 - 2*dur_crossfade) * GST_MSECOND,NULL);<div><br> g_object_set (op,"duration", dur_crossfade * GST_MSECOND,NULL);<br> g_object_set (op,"media-start", 0 * GST_MSECOND,NULL);<br>
g_object_set(op,"media-duration", dur_crossfade * GST_MSECOND,NULL);<br></div> g_object_set(op,"priority",0,NULL);<br><br> // Playin 3rd video, which is the first one played<div><br>
g_object_set (video2, "location", argv[1], NULL);<br>
g_object_set (video2,"uri",argv[1],NULL);<br></div> g_object_set (video2, "start", (dur1 + dur2 - 2*dur_crossfade) * GST_MSECOND, NULL);<div><br> g_object_set (video2, "duration", dur1 * GST_MSECOND, NULL);<br>
g_object_set (video2, "media-start", 0 * GST_MSECOND, NULL);<br> g_object_set (video2, "media-duration", dur1 * GST_MSECOND, NULL);<br></div> g_object_set (video2, "priority", 3,NULL);<div>
<div></div><div><br>
<br>}<br><br><br><br><div class="gmail_quote">2011/9/26 Angel Martin <span dir="ltr"><<a href="mailto:amartin@vicomtech.org" target="_blank">amartin@vicomtech.org</a>></span><br><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
Hello,<br><br>I suggest you to remove variable start and duration attributes and put fixed values instead in order to have a clear schedule of the different elements involved.<br><br>Moreover, the priority of the operation should be always minor that the videos involved, I suggest you to put a 0 always in the transition operation priority.<br>
<br>Best Regards,<br><br>Angel<br><br><div class="gmail_quote">2011/9/25 Rossana Guerra <span dir="ltr"><<a href="mailto:guerra.rossana@gmail.com" target="_blank">guerra.rossana@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
Hello everyone, I am trying to do crossfade between 3 videos. It works fine when I do the same with 2, but when I put the 3rd something happens and the player displays only the first.<br>Actually I use 2 videos, and I did a playlist such video1 -> video2 -> video2, where the 3rd time, I set the new starting time of the video2 object.<br>
<br>video1 starts at 0, and its durations is dur1<br>I use an operator to handle the alpha channel, it starts at dur1 - dur_crossfade<br>video2, starts at dur1 - dur_crossfade<br>And the starting time of video 2 the third time is dur1 + dur2 - dur_crossfade.<br>
<br>Maybe it's something wrong with the priority or start properties values, I am very new with GStreamer, I could make several mistakes.<br><br>Thanks and regards,<br><br>Rossana<br><br><br>Here's the code:<br><br>
<br>const gint dur_crossfade = 500;<br><br>// Error handler<br>static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)<br>{<br><br> :::::::::::::::::::::::::::::::::<br> return TRUE;<br>}<br><br>static void on_pad_added (GstElement *element, GstPad *pad, gpointer data)<br>
{<br> GstPad *sinkpad = NULL;<br> GstElement * queue = (GstElement *) data;<br><br> /* Ahora linkeo el pad de comp con sink pad */<br> g_print ("Dynamic pad created, linking queue\n");<br> sinkpad = gst_element_get_static_pad (queue, "sink");<br>
<br> gst_pad_link (pad, sinkpad);<br><br> gst_object_unref (sinkpad);<br><br>}<br><br>GstElement * getBin(const gchar * nomBin, GstElement * &alfa1, GstElement *&smpte, GstElement * &color, gint transicion = 1)<br>
{<br><br> GstElement * bin = gst_bin_new(nomBin);<br><br> if (!bin)<br> {<br> g_printerr ("No se pudo crear el bin. Saliendo\n");<br> return NULL;<br> }<br><br> alfa1 = gst_element_factory_make ("alpha","alfa1");<br>
smpte = gst_element_factory_make ("smptealpha","smpte");<br> color = gst_element_factory_make ("ffmpegcolorspace", "color");<br> GstElement * mixer = gst_element_factory_make("videomixer", "mixer");<br>
<br><br> if ((!alfa1) || (!smpte) || (!color) || (!mixer))<br> {<br> g_printerr ("Alguno de los elementos del Bin no pudo ser creado. Saliendo\n");<br> return NULL;<br> }<br><br> // Anexamos al bin<br>
gst_bin_add_many(GST_BIN (bin),alfa1,smpte,mixer,color,NULL);<br><br> // Enlazamos elementos<br> gst_element_link (alfa1, mixer);<br> gst_element_link (smpte, mixer);<br> gst_element_link (mixer,color);<br><br> g_object_set(smpte,"type", transicion, NULL);<br>
<br> return bin;<br>}<br><br>void getAndSetController(GstElement * smpte, gdouble duracion)<br>{<br> GstController * ctrl = NULL;<br> if (!(ctrl = gst_controller_new (G_OBJECT (smpte), "alpha",NULL))) {<br>
GST_WARNING ("No puede controlar el elemento fuente\n");<br> return;<br> }<br><br> // Todo valor GValue debe inicializarse en 0<br> GValue val_double = { 0, };<br> g_value_init (&val_double, G_TYPE_DOUBLE);<br>
<br><br> // Create de controller, source and set the interpolation mode<br><br> GstInterpolationControlSource * csource = gst_interpolation_control_source_new();<br> gst_controller_set_control_source (ctrl, "alpha", GST_CONTROL_SOURCE (csource));<br>
<br> gst_interpolation_control_source_set_interpolation_mode(csource,GST_INTERPOLATE_LINEAR);<br><br> // Set first value<br> g_value_set_double(&val_double, 0.0);<br> gst_interpolation_control_source_set(csource,(0 * GST_MSECOND),&val_double);<br>
<br> // Ser 2nd value<br> g_value_set_double (&val_double, duracion);<br> gst_interpolation_control_source_set(csource,(1 * GST_MSECOND),&val_double);<br><br><br> g_object_unref (csource);<br><br>}<br><br>void addGhostPadsToBin(GstElement *alfa1, GstElement * smpte, GstElement * color, GstElement* bin)<br>
{<br> /* add ghostpad */<br> GstPad * pad1 = gst_element_get_static_pad (alfa1, "sink");<br> gst_element_add_pad(bin, gst_ghost_pad_new("alfasink1", pad1));<br> gst_object_unref (GST_OBJECT (pad1));<br>
<br> GstPad * pad2 = gst_element_get_static_pad (smpte, "sink");<br> gst_element_add_pad(bin, gst_ghost_pad_new("alfasink2", pad2));<br> gst_object_unref(GST_OBJECT(pad2));<br><br> GstPad * pad3 = gst_element_get_static_pad (color, "src");<br>
gst_element_add_pad(bin, gst_ghost_pad_new("colorsrc", pad3));<br> gst_object_unref(GST_OBJECT(pad3));<br><br>}<br><br>void crossTransicion(gdouble duracion, GstElement * & bin,gint transicion = 1)<br>{<br>
// devuelve el bin<br> GstElement * alfa1, *smpte, *color;<br> alfa1 = 0;<br> smpte = 0;<br> color = 0;<br><br> bin = getBin("bin",alfa1, smpte,color,transicion); // Crea el bin y los elementos<br>
<br> getAndSetController(smpte,duracion);<br><br> addGhostPadsToBin(alfa1, smpte, color, bin);<br><br>}<br><br>GstElement * crearVideo(const gchar *nomVideo, GstElement *&comp)<br>{<br> GstElement* video = NULL;<br>
if ((video = gst_element_factory_make("gnlfilesource", nomVideo)) == NULL)<br> {<br> printf ("\n Falló la creacion del gnlfilesource \n");<br> return NULL;<br> }<br><br><br> if (gst_bin_add (GST_BIN (comp), video) == FALSE)<br>
{<br> printf ("\n No pudo agregar video %s a comp \n", nomVideo);<br> return NULL;<br> }<br><br> return video;<br>}<br><br>void crearCompYoper(GstElement*& compo, GstElement *&op, GstElement*& bin2)<br>
{<br><br> if ((compo = gst_element_factory_make("gnlcomposition", "micomposicion")) == NULL)<br> {<br> printf ("\n Fallo al crear gnlcomposition \n");<br> return;<br> }<br>
<br> //Aqui se crea el bin<br> crossTransicion(dur_crossfade, bin2,1);<br><br> op = gst_element_factory_make("gnloperation", "op");<br><br> if (gst_bin_add (GST_BIN (op), bin2) == FALSE)<br>
{<br> printf ("\n No pudo agregar el bin a la gnloperacion op \n");<br> return;<br> }<br><br> if (gst_bin_add (GST_BIN (compo), op) == FALSE)<br> {<br> printf ("\n No pudo agregar la gnloperacion a la gnlcomposition \n");<br>
return;<br> }<br><br>}<br><br><br>/// Aqui pipeline3<br><br>GstElement * getPipeline3(gchar *argv[],GstElement *&video1, gint dur1, GstElement *& video2,GstElement *& comp, GstElement *&op)<br>{<br>
<br> GstElement *queue, *sink, *pipeline, *bin;<br><br> crearCompYoper(comp, op,bin);<br><br> video1 = crearVideo("video1",comp);<br> video2 = crearVideo("video2",comp);<br><br> g_object_set (video1, "location", argv[1], NULL);<br>
g_object_set(video1, "uri", argv[1],NULL);<br> g_object_set (video1, "start", 0 * GST_MSECOND, NULL);<br> g_object_set (video1, "duration", dur1 * GST_MSECOND, NULL);<br> g_object_set (video1, "media-start", 0* GST_MSECOND, NULL);<br>
g_object_set (video1, "media-duration", dur1 * GST_MSECOND, NULL);<br> g_object_set (video1, "priority", 1,NULL);<br><br> // setup the backend viewer<br> queue = gst_element_factory_make("queue", "queue");<br>
sink = gst_element_factory_make("autovideosink", "sink");<br><br> pipeline = gst_pipeline_new ("video-player");<br><br> /* Agrego elementos al pipeline */<br><br> gst_bin_add_many (GST_BIN (pipeline),comp, queue, sink, NULL);<br>
<br> g_signal_connect (comp, "pad-added", G_CALLBACK (on_pad_added),queue);<br><br> gst_element_link (queue, sink);<br><br> cout << "...PLAY" << endl;<br><br> gst_element_set_state (pipeline, GST_STATE_PLAYING);<br>
<br> return pipeline;<br>}<br><br><br>void playSigVideo(gchar *argv[], GstElement *& video2, gint dur1, gint dur2,GstElement *&op, GstElement *pip)<br>{<br> g_object_set (op,"start", (dur1-dur_crossfade) * GST_MSECOND,NULL);<br>
g_object_set (op,"duration", dur_crossfade * GST_MSECOND,NULL);<br> g_object_set (op,"media-start", 0 * GST_MSECOND,NULL);<br> g_object_set(op,"media-duration", dur_crossfade * GST_MSECOND,NULL);<br>
g_object_set(op,"priority",0,NULL);<br><br> gst_element_set_state (pip, GST_STATE_PLAYING);<br><br> g_object_set (video2, "location", argv[2], NULL);<br> g_object_set (video2,"uri",argv[2],NULL);<br>
g_object_set (video2, "start", (dur1-dur_crossfade) * GST_MSECOND, NULL);<br> g_object_set (video2, "duration", dur2 * GST_MSECOND, NULL);<br> g_object_set (video2, "media-start", 0 * GST_MSECOND, NULL);<br>
g_object_set (video2, "media-duration", dur2 * GST_MSECOND, NULL);<br> g_object_set (video2, "priority", 2,NULL);<br><br> g_object_set (op,"start", ((dur2+dur1)- 2*dur_crossfade) * GST_MSECOND,NULL);<br>
g_object_set (op,"duration", dur_crossfade * GST_MSECOND,NULL);<br> g_object_set (op,"media-start", 0 * GST_MSECOND,NULL);<br> g_object_set(op,"media-duration", dur_crossfade * GST_MSECOND,NULL);<br>
g_object_set(op,"priority",3,NULL);<br><br> g_object_set (video2, "location", argv[1], NULL);<br> g_object_set (video2,"uri",argv[1],NULL);<br> g_object_set (video2, "start", ((dur2 + dur1) - 2*dur_crossfade) * GST_MSECOND, NULL);<br>
g_object_set (video2, "duration", dur1 * GST_MSECOND, NULL);<br> g_object_set (video2, "media-start", 0 * GST_MSECOND, NULL);<br> g_object_set (video2, "media-duration", dur1 * GST_MSECOND, NULL);<br>
g_object_set (video2, "priority", 4,NULL);<br><br>}<br><br><br>int main(gint argc, gchar *argv[])<br>{<br> gint dur1 = 9000; // d uration (in ms) to play of first clip<br> gint dur2 = 8000; // duration (in ms) to play of second clip<br>
//gint dur_crossfade = 500; //number of milliseconds to crossfade for<br> GMainLoop *loop = NULL;<br><br> /* init GStreamer */<br> gst_init (&argc, &argv);<br> gst_controller_init (&argc, &argv);<br>
<br> loop = g_main_loop_new (NULL, FALSE);<br><br> /* chequeamos sintaxis */<br> if (argc != 3)<br> {<br> g_print ("Uso: %s <URI1> <URI2>\n", argv[0]);<br> return -1;<br> }<br>
<br> GstElement *comp = NULL;<br> GstElement *op = NULL;<br> GstElement *video1,*video2;<br><br> GstElement *play = getPipeline3(argv,video1, dur1,video2,comp, op);<br><br> playSigVideo(argv,video2, dur1, dur2,op,play);<br>
<br> GstBus *bus2 = gst_pipeline_get_bus (GST_PIPELINE (play));<br> gst_bus_add_watch (bus2, bus_call, loop);<br> gst_object_unref (bus2);<br><br> //cout << "...PLAY" << endl;<br> <br>
<br>
/* now run */<br> g_main_loop_run (loop);<br><br> /* also clean up */<br> gst_element_set_state (play, GST_STATE_NULL);<br> gst_object_unref (GST_OBJECT (play));<br> return 0;<br>}<br><br><br><br>
<br>_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
<br></blockquote></div><br><br>
<br>_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
<br></blockquote></div><br>
</div></div></blockquote></div><br>
</div></div><br>_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
<br></blockquote></div><br><br clear="all"><br>
</div></div><br>_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
<br></blockquote></div><br></div></div>