dynamic change element's parameter

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

dynamic change element's parameter

Chandler Li
Hi all,
    I'm new to use gstreamer,
    and I have a problem don't know how to solve for a long time,

    Is there possible to dynamic change the parameter in elements or pads?

    For example,
    In a playing state streaming,
    could I dynamic change the size of video without stop the streaming?

    hopes that's not a stupid question,
    and very hopefully for your reply,
    Thank you

    Chandler Lee

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: dynamic change element's parameter

Mailing List SVR
Il giorno dom, 12/09/2010 alle 14.01 +0800, Chandler Li ha scritto:
> Hi all,
>     I'm new to use gstreamer,
>     and I have a problem don't know how to solve for a long time,
>
>     Is there possible to dynamic change the parameter in elements or pads?
>
>     For example,
>     In a playing state streaming,
>     could I dynamic change the size of video without stop the streaming?

I think you can following the directions here:

http://cgit.freedesktop.org/gstreamer/gstreamer/tree/docs/design/part-block.txt

for your use case I'll try to insert a videoscale element in the running
pipeline,

be warned if you are saving the stream in a file and you dynamically
change the file destination you'll have timestamp problems:

https://bugzilla.gnome.org/show_bug.cgi?id=561224

hope this help,

Nicola


>
>     hopes that's not a stupid question,
>     and very hopefully for your reply,
>     Thank you
>
>     Chandler Lee
>
> ------------------------------------------------------------------------------
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing
> http://p.sf.net/sfu/novell-sfdev2dev
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: dynamic change element's parameter

Stefan Sauer
In reply to this post by Chandler Li
Am 12.09.2010 09:01, schrieb Chandler Li:
> Hi all,
>     I'm new to use gstreamer,
>     and I have a problem don't know how to solve for a long time,
>
>     Is there possible to dynamic change the parameter in elements or pads?

gobject parameters -> g_object_set or use GstController


>
>     For example,
>     In a playing state streaming,
>     could I dynamic change the size of video without stop the streaming?

yes you can. if you resize the video window for xvimagesink the video adjusts if
it can. So if you run gst-launch videotestsrc ! xvimagesink, the videotest is
sending videoframes in the native resolution instead of xvimagesink scaling them.

Stefan

>
>     hopes that's not a stupid question,
>     and very hopefully for your reply,
>     Thank you
>
>     Chandler Lee
>
> ------------------------------------------------------------------------------
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing
> http://p.sf.net/sfu/novell-sfdev2dev
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: dynamic change element's parameter

Chandler Li
I have read the mail Nicola and Stefan given, and that really inspired
me a lot.
Thank you!
In the first, I try to replace some elements and encounter some
problem, the following I will show my target first.
Because I want to stream webcam frame on the internet,
and dynamically change the frame size without stopping the pipeline.

According to my experience, if the v4l2src element opens webcam
device, it only captures one size at one time.
if I want to change the size of webcam, I need to restart it.
So I try another architecture of gstreamer,

    v4l2src  ->  capsfilter1  ->  videoscale -> capsfilter2  ->
ffmpegcolorspace ->   .... (to internet)

videoscale links two filters, the first filter (capsfilter1)
negotiates with v4l2src in a static frame size,
I want to change the size I assigned in the second filter (capsfilter2) ,

BUT I get an error message after I change the capsfilter2 to the new filter,

    videoscale can't link to new capsfilter,

I don't know what's happened? does anyone know that?
Thank you!

Best regards,
Chandler Lee.

2010/9/14 Stefan Kost <[hidden email]>:

> Am 12.09.2010 09:01, schrieb Chandler Li:
>> Hi all,
>>     I'm new to use gstreamer,
>>     and I have a problem don't know how to solve for a long time,
>>
>>     Is there possible to dynamic change the parameter in elements or pads?
>
> gobject parameters -> g_object_set or use GstController
>
>
>>
>>     For example,
>>     In a playing state streaming,
>>     could I dynamic change the size of video without stop the streaming?
>
> yes you can. if you resize the video window for xvimagesink the video adjusts if
> it can. So if you run gst-launch videotestsrc ! xvimagesink, the videotest is
> sending videoframes in the native resolution instead of xvimagesink scaling them.
>
> Stefan
>
>>
>>     hopes that's not a stupid question,
>>     and very hopefully for your reply,
>>     Thank you
>>
>>     Chandler Lee
>>
>> ------------------------------------------------------------------------------
>> Start uncovering the many advantages of virtual appliances
>> and start using them to simplify application deployment and
>> accelerate your shift to cloud computing
>> http://p.sf.net/sfu/novell-sfdev2dev
>> _______________________________________________
>> gstreamer-devel mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: dynamic change element's parameter

Stefan Sauer
On 14.09.2010 10:48, Chandler Li wrote:

> I have read the mail Nicola and Stefan given, and that really inspired
> me a lot.
> Thank you!
> In the first, I try to replace some elements and encounter some
> problem, the following I will show my target first.
> Because I want to stream webcam frame on the internet,
> and dynamically change the frame size without stopping the pipeline.
>
> According to my experience, if the v4l2src element opens webcam
> device, it only captures one size at one time.
> if I want to change the size of webcam, I need to restart it.
>  

v4l2src does not support changing the resolution on the fly. This is a
v4l2 interface limitation right now - one needs to stop streaming, set
new format and restart streaming. So your observation is correct.

> So I try another architecture of gstreamer,
>
>     v4l2src  ->  capsfilter1  ->  videoscale -> capsfilter2  ->
> ffmpegcolorspace ->   .... (to internet)
>
> videoscale links two filters, the first filter (capsfilter1)
> negotiates with v4l2src in a static frame size,
> I want to change the size I assigned in the second filter (capsfilter2) ,
>
> BUT I get an error message after I change the capsfilter2 to the new filter,
>
>     videoscale can't link to new capsfilter,
>  

that should work. Can you paste a few lines of the code here. You should
create new caps and just set the new format on capsfilter2.

Stefan

> I don't know what's happened? does anyone know that?
> Thank you!
>
> Best regards,
> Chandler Lee.
>
> 2010/9/14 Stefan Kost <[hidden email]>:
>  
>> Am 12.09.2010 09:01, schrieb Chandler Li:
>>    
>>> Hi all,
>>>     I'm new to use gstreamer,
>>>     and I have a problem don't know how to solve for a long time,
>>>
>>>     Is there possible to dynamic change the parameter in elements or pads?
>>>      
>> gobject parameters -> g_object_set or use GstController
>>
>>
>>    
>>>     For example,
>>>     In a playing state streaming,
>>>     could I dynamic change the size of video without stop the streaming?
>>>      
>> yes you can. if you resize the video window for xvimagesink the video adjusts if
>> it can. So if you run gst-launch videotestsrc ! xvimagesink, the videotest is
>> sending videoframes in the native resolution instead of xvimagesink scaling them.
>>
>> Stefan
>>
>>    
>>>     hopes that's not a stupid question,
>>>     and very hopefully for your reply,
>>>     Thank you
>>>
>>>     Chandler Lee
>>>
>>> ------------------------------------------------------------------------------
>>> Start uncovering the many advantages of virtual appliances
>>> and start using them to simplify application deployment and
>>> accelerate your shift to cloud computing
>>> http://p.sf.net/sfu/novell-sfdev2dev
>>> _______________________________________________
>>> gstreamer-devel mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>>>      
>>
>>    


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: dynamic change element's parameter

Chandler Li
Thank you,
I paste the key point code to there,

the old one caps:
               caps1 = gst_caps_new_simple ("video/x-raw-yuv",
       "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
              "width", G_TYPE_INT, 123,
              "height", G_TYPE_INT, 456,
              "framerate", GST_TYPE_FRACTION, 30, 1,
              NULL);
the new one caps:
              caps2 = gst_caps_new_simple ("video/x-raw-yuv",
       "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
              "width", G_TYPE_INT, 456,
              "height", G_TYPE_INT, 789,
              "framerate", GST_TYPE_FRACTION, 30, 1,
              NULL);
and the folowing code change caps:
                gst_pad_set_blocked_async(pad,TRUE,my_blocked_callback,NULL);
                gst_element_set_state(GST_ELEMENT(capsfilter2), GST_STATE_NULL);
                g_object_set (G_OBJECT (capsfilter2), "caps",caps2,NULL);
                gst_element_set_state(GST_ELEMENT(capsfilter2), GST_STATE_PLAYING);
                gst_pad_set_blocked_async(pad,FALSE,my_blocked_callback,NULL);

First, I block the videoscale's src pad. Then turn the the element
capsfilter2 to NULL , give it new caps with different width and
height.
After that, I turn the element capsfilter2 to PLAYING, and unblock the
videoscale's src pad.

after doing these, I get wrong message
               ** ERROR **: Internal data flow error.
               aborting...

But if I let the caps2's format same with caps1:
              caps2 = gst_caps_new_simple ("video/x-raw-yuv",
       "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
              "width", G_TYPE_INT, 123,
              "height", G_TYPE_INT, 456,
              "framerate", GST_TYPE_FRACTION, 30, 1,
              NULL);

The streaming still works. It's really strange.
I think it's because of the videoscale problem.
Did I lose any detail in the code?

Thank you!
Best regards,
Chandler Lee.

2010/9/14 Stefan Kost <[hidden email]>:

> On 14.09.2010 10:48, Chandler Li wrote:
>> I have read the mail Nicola and Stefan given, and that really inspired
>> me a lot.
>> Thank you!
>> In the first, I try to replace some elements and encounter some
>> problem, the following I will show my target first.
>> Because I want to stream webcam frame on the internet,
>> and dynamically change the frame size without stopping the pipeline.
>>
>> According to my experience, if the v4l2src element opens webcam
>> device, it only captures one size at one time.
>> if I want to change the size of webcam, I need to restart it.
>>
>
> v4l2src does not support changing the resolution on the fly. This is a
> v4l2 interface limitation right now - one needs to stop streaming, set
> new format and restart streaming. So your observation is correct.
>
>> So I try another architecture of gstreamer,
>>
>>     v4l2src  ->  capsfilter1  ->  videoscale -> capsfilter2  ->
>> ffmpegcolorspace ->   .... (to internet)
>>
>> videoscale links two filters, the first filter (capsfilter1)
>> negotiates with v4l2src in a static frame size,
>> I want to change the size I assigned in the second filter (capsfilter2) ,
>>
>> BUT I get an error message after I change the capsfilter2 to the new filter,
>>
>>     videoscale can't link to new capsfilter,
>>
>
> that should work. Can you paste a few lines of the code here. You should
> create new caps and just set the new format on capsfilter2.
>
> Stefan
>> I don't know what's happened? does anyone know that?
>> Thank you!
>>
>> Best regards,
>> Chandler Lee.
>>
>> 2010/9/14 Stefan Kost <[hidden email]>:
>>
>>> Am 12.09.2010 09:01, schrieb Chandler Li:
>>>
>>>> Hi all,
>>>>     I'm new to use gstreamer,
>>>>     and I have a problem don't know how to solve for a long time,
>>>>
>>>>     Is there possible to dynamic change the parameter in elements or pads?
>>>>
>>> gobject parameters -> g_object_set or use GstController
>>>
>>>
>>>
>>>>     For example,
>>>>     In a playing state streaming,
>>>>     could I dynamic change the size of video without stop the streaming?
>>>>
>>> yes you can. if you resize the video window for xvimagesink the video adjusts if
>>> it can. So if you run gst-launch videotestsrc ! xvimagesink, the videotest is
>>> sending videoframes in the native resolution instead of xvimagesink scaling them.
>>>
>>> Stefan
>>>
>>>
>>>>     hopes that's not a stupid question,
>>>>     and very hopefully for your reply,
>>>>     Thank you
>>>>
>>>>     Chandler Lee
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Start uncovering the many advantages of virtual appliances
>>>> and start using them to simplify application deployment and
>>>> accelerate your shift to cloud computing
>>>> http://p.sf.net/sfu/novell-sfdev2dev
>>>> _______________________________________________
>>>> gstreamer-devel mailing list
>>>> [hidden email]
>>>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>>>>
>>>
>>>
>
>

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: dynamic change element's parameter

Stefan Sauer
On 14.09.2010 16:37, Chandler Li wrote:

> Thank you,
> I paste the key point code to there,
>
> the old one caps:
>                caps1 = gst_caps_new_simple ("video/x-raw-yuv",
>        "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
>      "width", G_TYPE_INT, 123,
>      "height", G_TYPE_INT, 456,
>      "framerate", GST_TYPE_FRACTION, 30, 1,
>      NULL);
> the new one caps:
>               caps2 = gst_caps_new_simple ("video/x-raw-yuv",
>        "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
>      "width", G_TYPE_INT, 456,
>      "height", G_TYPE_INT, 789,
>      "framerate", GST_TYPE_FRACTION, 30, 1,
>      NULL);
> and the folowing code change caps:
>                 gst_pad_set_blocked_async(pad,TRUE,my_blocked_callback,NULL);
> gst_element_set_state(GST_ELEMENT(capsfilter2), GST_STATE_NULL);
> g_object_set (G_OBJECT (capsfilter2), "caps",caps2,NULL);
> gst_element_set_state(GST_ELEMENT(capsfilter2), GST_STATE_PLAYING);
> gst_pad_set_blocked_async(pad,FALSE,my_blocked_callback,NULL);
>  
ohh, you can just set the caps. I mean just do:

g_object_set (G_OBJECT (capsfilter2), "caps",caps2,NULL);


Stefan

> First, I block the videoscale's src pad. Then turn the the element
> capsfilter2 to NULL , give it new caps with different width and
> height.
> After that, I turn the element capsfilter2 to PLAYING, and unblock the
> videoscale's src pad.
>
> after doing these, I get wrong message
>                ** ERROR **: Internal data flow error.
>                aborting...
>
> But if I let the caps2's format same with caps1:
>               caps2 = gst_caps_new_simple ("video/x-raw-yuv",
>        "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
>      "width", G_TYPE_INT, 123,
>      "height", G_TYPE_INT, 456,
>      "framerate", GST_TYPE_FRACTION, 30, 1,
>      NULL);
>
> The streaming still works. It's really strange.
> I think it's because of the videoscale problem.
> Did I lose any detail in the code?
>
> Thank you!
> Best regards,
> Chandler Lee.
>
> 2010/9/14 Stefan Kost <[hidden email]>:
>  
>> On 14.09.2010 10:48, Chandler Li wrote:
>>    
>>> I have read the mail Nicola and Stefan given, and that really inspired
>>> me a lot.
>>> Thank you!
>>> In the first, I try to replace some elements and encounter some
>>> problem, the following I will show my target first.
>>> Because I want to stream webcam frame on the internet,
>>> and dynamically change the frame size without stopping the pipeline.
>>>
>>> According to my experience, if the v4l2src element opens webcam
>>> device, it only captures one size at one time.
>>> if I want to change the size of webcam, I need to restart it.
>>>
>>>      
>> v4l2src does not support changing the resolution on the fly. This is a
>> v4l2 interface limitation right now - one needs to stop streaming, set
>> new format and restart streaming. So your observation is correct.
>>
>>    
>>> So I try another architecture of gstreamer,
>>>
>>>     v4l2src  ->  capsfilter1  ->  videoscale -> capsfilter2  ->
>>> ffmpegcolorspace ->   .... (to internet)
>>>
>>> videoscale links two filters, the first filter (capsfilter1)
>>> negotiates with v4l2src in a static frame size,
>>> I want to change the size I assigned in the second filter (capsfilter2) ,
>>>
>>> BUT I get an error message after I change the capsfilter2 to the new filter,
>>>
>>>     videoscale can't link to new capsfilter,
>>>
>>>      
>> that should work. Can you paste a few lines of the code here. You should
>> create new caps and just set the new format on capsfilter2.
>>
>> Stefan
>>    
>>> I don't know what's happened? does anyone know that?
>>> Thank you!
>>>
>>> Best regards,
>>> Chandler Lee.
>>>
>>> 2010/9/14 Stefan Kost <[hidden email]>:
>>>
>>>      
>>>> Am 12.09.2010 09:01, schrieb Chandler Li:
>>>>
>>>>        
>>>>> Hi all,
>>>>>     I'm new to use gstreamer,
>>>>>     and I have a problem don't know how to solve for a long time,
>>>>>
>>>>>     Is there possible to dynamic change the parameter in elements or pads?
>>>>>
>>>>>          
>>>> gobject parameters -> g_object_set or use GstController
>>>>
>>>>
>>>>
>>>>        
>>>>>     For example,
>>>>>     In a playing state streaming,
>>>>>     could I dynamic change the size of video without stop the streaming?
>>>>>
>>>>>          
>>>> yes you can. if you resize the video window for xvimagesink the video adjusts if
>>>> it can. So if you run gst-launch videotestsrc ! xvimagesink, the videotest is
>>>> sending videoframes in the native resolution instead of xvimagesink scaling them.
>>>>
>>>> Stefan
>>>>
>>>>
>>>>        
>>>>>     hopes that's not a stupid question,
>>>>>     and very hopefully for your reply,
>>>>>     Thank you
>>>>>
>>>>>     Chandler Lee
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Start uncovering the many advantages of virtual appliances
>>>>> and start using them to simplify application deployment and
>>>>> accelerate your shift to cloud computing
>>>>> http://p.sf.net/sfu/novell-sfdev2dev
>>>>> _______________________________________________
>>>>> gstreamer-devel mailing list
>>>>> [hidden email]
>>>>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>>>>>
>>>>>          
>>>>
>>>>        
>>
>>    


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: dynamic change element's parameter

HaroldJRoth
Stefan Kost wrote
On 14.09.2010 16:37, Chandler Li wrote:
> Thank you,
> I paste the key point code to there,
>
> the old one caps:
>                caps1 = gst_caps_new_simple ("video/x-raw-yuv",
>        "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
>      "width", G_TYPE_INT, 123,
>      "height", G_TYPE_INT, 456,
>      "framerate", GST_TYPE_FRACTION, 30, 1,
>      NULL);
> the new one caps:
>               caps2 = gst_caps_new_simple ("video/x-raw-yuv",
>        "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
>      "width", G_TYPE_INT, 456,
>      "height", G_TYPE_INT, 789,
>      "framerate", GST_TYPE_FRACTION, 30, 1,
>      NULL);
> and the folowing code change caps:
>                 gst_pad_set_blocked_async(pad,TRUE,my_blocked_callback,NULL);
> gst_element_set_state(GST_ELEMENT(capsfilter2), GST_STATE_NULL);
> g_object_set (G_OBJECT (capsfilter2), "caps",caps2,NULL);
> gst_element_set_state(GST_ELEMENT(capsfilter2), GST_STATE_PLAYING);
> gst_pad_set_blocked_async(pad,FALSE,my_blocked_callback,NULL);
>  
ohh, you can just set the caps. I mean just do:

g_object_set (G_OBJECT (capsfilter2), "caps",caps2,NULL);

Stefan
The above advice works great.

For absolute beginners, here's a code sample that details how to get the capsfilter element reference:

        // We want to link the inputChain to the video queue using a
        // caps filter element.  That filter will allow us to adjust the
        // height and width used by the videoscaler at the end of the
        // the input chain (not shown here).
        //
        mVideoScaleFilter = gst_element_factory_make("capsfilter", NULL);
        g_assert(mVideoScaleFilter);

        // Predefined GstCaps makes no assumptions about width/height.
        //
        GstCaps* videoCaps = gst_caps_new_simple("video/x-raw-yuv", "format",
                        GST_TYPE_FOURCC, GST_MAKE_FOURCC('I', '4', '2', '0'), NULL);

        g_object_set(G_OBJECT(mVideoScaleFilter), "caps", videoCaps, NULL);

        // Now, add filter to pipeline, link it up
        //
        gst_bin_add_many(GST_BIN(mGstPipeline),
        mVideoScaleFilter,
        NULL);

        linkRes = gst_element_link_many( inputChain, mVideoScaleFilter, mVideoQueue, NULL);
                if (!linkRes){
                        // Inform logger of error!
        }

        // Discard caps reference.  GstElement references are object members,
        // they are unreferenced in the dtor.
        //
        gst_caps_unref(videoCaps);


AND here's how to set that filter later on.  'width' and 'height' are function arguments.  Notice that this works with the pipeline in a PLAYING state.

        GstCaps* videoCaps = gst_caps_new_simple("video/x-raw-yuv",
                                                        "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC('I', '4', '2', '0'),
                                                        "width", G_TYPE_INT, width,
                                                        "height", G_TYPE_INT, height,
                                                        NULL);
        g_assert(videoCaps);
        g_assert(mVideoScaleFilter);
        g_object_set(G_OBJECT(mVideoScaleFilter), "caps", videoCaps, NULL);
        gst_caps_unref(videoCaps);

Reply | Threaded
Open this post in threaded view
|

Re: dynamic change element's parameter

HaroldJRoth
BTW, how would I put the videoscaler element back into pass through mode.  I.e. if I want it to stop scaling?  

Do I get the sink pad and use its caps for width/height, or is their another value I can send to it from the capsfilter that will put the videoscaler back into the state it was before I changed the width/height?
Reply | Threaded
Open this post in threaded view
|

Re: dynamic change element's parameter

ClaudioSSBT
Hello,
I'm trying to follow your suggestion, chaing the framerate property of the cap, while pipeline is running but it seems not work.

First time:

        caps1 = gst_caps_new_simple ("video/x-raw-yuv",
                        "framerate", GST_TYPE_FRACTION, framerateNum, framerateDen,
                          NULL);
        videoflt1 = gst_element_factory_make ("capsfilter", "video-filter1");
        g_assert (videoflt1);
        g_object_set (G_OBJECT (videoflt1), "caps",caps1, NULL);



Then when I want to change framerate:

Caps1 = gst_caps_new_simple ("video/x-raw-yuv",
                                "framerate", GST_TYPE_FRACTION, framerateNum, framerateDen,
                                  NULL);
        g_object_set (G_OBJECT (videoflt1), "caps",Caps1, NULL);

but the framerate doesn't change !
Before the capfilter, there is videorate element.


Thanks!
Claudio

Reply | Threaded
Open this post in threaded view
|

Re: dynamic change element's parameter

bboyavatar
In reply to this post by Chandler Li
I have the same problem as you said. I use g_timeout_add(2000,GSourceFunc)update_time_callback, pipeline) function to change the element's parameter when  the pipeline is running periodically. In the callback function update_time_callback, I changed the capsfilter's caps property which was placed after videoscale. I read the width and height properties from the capfilter, and they did changed. But the videosize did not change in the videosink(xvimagesink). I don't know what is the problem, could some one tell me the reason? Thanks so much!