HOWTO change filter settings while playing ?

Microsoft Windows specific usage questions
Forum rules
Please post only Windows specific questions in this forum category. If you don't know where to post, please read the different forums' rules. Thanks.
elwood
Blank Cone
Blank Cone
Posts: 24
Joined: 04 Oct 2008 15:28

HOWTO change filter settings while playing ?

Postby elwood » 04 Oct 2008 15:38

Hi, I need to manipulate with settings such as "Contrast", "Brightness" and others while player is playing video, using libvlc 0.9.2 API.
I found some interfaces in libvlccore.dll (__var_Get, __var_Change, ..), but don't know, how initialize a chain of filters (adjust filter in 1st order), how connect that chain to mediaplayer's output, and how I can dynamically change filter' settings.

Simple adding parameters to vlc_instance_new() - that works, but it doesn't provide feature to manage this settings in real-time.

Thanks for any answers,
sry if my English is bad

elwood
Blank Cone
Blank Cone
Posts: 24
Joined: 04 Oct 2008 15:28

Re: HOWTO change filter settings while playing ?

Postby elwood » 05 Oct 2008 14:28

Nobody knows ? :(

VLC_help
Mega Cone Master
Mega Cone Master
Posts: 25661
Joined: 13 Sep 2006 14:16

Re: HOWTO change filter settings while playing ?

Postby VLC_help » 05 Oct 2008 17:42

According to adjust.c they should have callbacks

Code: Select all

var_AddCallback( p_filter, "contrast", AdjustCallback, p_sys ); var_AddCallback( p_filter, "brightness", AdjustCallback, p_sys ); var_AddCallback( p_filter, "hue", AdjustCallback, p_sys ); var_AddCallback( p_filter, "saturation", AdjustCallback, p_sys ); var_AddCallback( p_filter, "gamma", AdjustCallback, p_sys ); var_AddCallback( p_filter, "brightness-threshold", AdjustCallback, p_sys );

elwood
Blank Cone
Blank Cone
Posts: 24
Joined: 04 Oct 2008 15:28

Re: HOWTO change filter settings while playing ?

Postby elwood » 05 Oct 2008 20:30

callbacks ? but I need only to locate vlc_object, associated with adjust filter, and change / set its variables
I think using callbacks is not perfect in my case, because code written in C# CLR; and using callback calls from unmanaged code to managed is not well-safe

VLC_help
Mega Cone Master
Mega Cone Master
Posts: 25661
Joined: 13 Sep 2006 14:16

Re: HOWTO change filter settings while playing ?

Postby VLC_help » 06 Oct 2008 10:55

I think you can change the values, but you also have to tell to that filter those values have changed (if you want to change them on runtime). So that is why I think callback should be used (I am not 100% sure about this).

elwood
Blank Cone
Blank Cone
Posts: 24
Joined: 04 Oct 2008 15:28

Re: HOWTO change filter settings while playing ?

Postby elwood » 06 Oct 2008 18:18

Ok, thx, will try tomorrow )

elwood
Blank Cone
Blank Cone
Posts: 24
Joined: 04 Oct 2008 15:28

Re: HOWTO change filter settings while playing ?

Postby elwood » 08 Oct 2008 18:53

there are some problems was appeared
What did I do ?

(I have an initialized vlc_instance_t, media_player_t)
1) Get vout object, using vlc_instance_t->p_libvlc_int:
vlc_object * vout_object = __vlc_object_find(vlc_instance_t->p_libvlc_int, VLC_OBJECT_VOUT, FIND_CHILD)
2) Get or Set parameters of vout, like
__var_Get(vout_object, .......);

In first step I received a very strange struct, probably it wasn't an instance of vout_thread_t struct. And all code after that behaved very strange, too.
(I tried other methodics too, like searching by string "vout-filter" or filter by name "adjust")

What have I made incorrectly ?

VLC_help
Mega Cone Master
Mega Cone Master
Posts: 25661
Joined: 13 Sep 2006 14:16

Re: HOWTO change filter settings while playing ?

Postby VLC_help » 09 Oct 2008 20:57

Where did you get the basecode?

Erwan100
Blank Cone
Blank Cone
Posts: 14
Joined: 05 Sep 2008 20:04

Re: HOWTO change filter settings while playing ?

Postby Erwan100 » 10 Oct 2008 03:38

Hi,

You can do something along this line :

1) play a media with an option like : "--video-filter=adjust@my_label"

2) retrieve the internal reference to the first object libvlc
int object_id = libvlc_get_vlc_id( p_vlc_instance );
vlc_object_t* p_libvlc = (vlc_object_t *) vlc_object_get ( object_id );

3) retrieve the filter object named my_label
vlc_object_t* p_filter = (vlc_object_t *) vlc_object_find_name( p_libvlc, "my_label", FIND_CHILD );

4) Get or Set the variables associated with this object, for example :
int hue = var_GetInteger ( p_filter, "hue" )
var_SetInteger(( p_filter, "hue", new_hue )

The variables available for this filter are the following :
(excerpt from the command "vars my_label" from the rc interface)

o 00000739 filter "my_label", refcount 2, parent 731
|-o "brightness" (float), command, 1 callbacks: 1.000000
|-o "gamma" (float), command, 1 callbacks: 1.000000
|-o "hue" (integer), command, 1 callbacks: 0
|-o "saturation" (float), command, 1 callbacks: 1.000000
|-o "brightness-threshold" (bool), command, 1 callbacks: false
`-o "contrast" (float), command, 1 callbacks: 1.000000

each type float, integer or boolean has got its own var_Getxxx/varSetxxx functions.
the @my_label is optional but it makes it simpler to address the right filter should you use several inputs.

Actually, this method addresses a lot of issues not directly accessible through the libvlc API.

elwood
Blank Cone
Blank Cone
Posts: 24
Joined: 04 Oct 2008 15:28

Re: HOWTO change filter settings while playing ?

Postby elwood » 10 Oct 2008 11:02

VLC_help, I viewed many sources, including an examples of using older versions (0.8.6), .NET interfaces (from wiki);

Erwan100, thanks for a detailed answer, but I tried this code and found that

Code: Select all

vlc_object_t* p_filter = (vlc_object_t *) vlc_object_find_name( p_libvlc, "my_label", FIND_CHILD );
returns null pointer.

I wrote small recoursive function for dump all objects begining from object, associated with libvlc_instance_t:
name='libvlc' type='libvlc' typeid='-2'
- name='' type='interaction' typeid='-666'
- name='' type='playlist' typeid='-666'
- - name='' type='preparser' typeid='-666'
- - name='' type='fetcher' typeid='-666'
- name='hotkeys' type='interface' typeid='-4'
- name='' type='input' typeid='-7'
- - name='access_file' type='access' typeid='-666'
- - - name='' type='stream' typeid='-666'
- - name='avi' type='demux' typeid='-666'
- - name='avcodec' type='decoder' typeid='-8'
- - - name='vout_directx' type='video output' typeid='-9'
- - - - name='' type='subpicture' typeid='-666'
- - - - name='' type='generic' typeid='-666'
- - name='mpeg_audio' type='decoder' typeid='-8'
- - - name='aout_directx' type='audio output' typeid='-10'
- - - - name='' type='generic' typeid='-666'
- - - - name='converter_float' type='audio output' typeid='-666'
- - - - name='mpgatofixed32' type='audio output' typeid='-666'
- - - - name='bandlimited_resampler' type='audio output' typeid='-666'
As you can see, there are no filter objects appeared. (was dumped while playing)

elwood
Blank Cone
Blank Cone
Posts: 24
Joined: 04 Oct 2008 15:28

Re: HOWTO change filter settings while playing ?

Postby elwood » 10 Oct 2008 11:14

Ow, sorry, that works !
But options are added not to media. It is needed to initialize the libvlc_instance
where calling

Code: Select all

libvlc_instance_t * libvlc_new (int argc, const char *const * argv, libvlc_exception_t *)
thanks for a help )

Erwan100
Blank Cone
Blank Cone
Posts: 14
Joined: 05 Sep 2008 20:04

Re: HOWTO change filter settings while playing ?

Postby Erwan100 » 10 Oct 2008 12:49

My understanding is that this should work for both (either at the libvlc level or at the media level).
If you manage several medias concurrently, it is better to do it at the media level.

Also if you use a chain of filters, it is better to do it at this level. I suppose you can even use the same filter several times in a chain and still be able to control each filter independently by assigning a different name to them. (not tested, just an assumption)


Return to “VLC media player for Windows Troubleshooting”

Who is online

Users browsing this forum: Google [Bot] and 53 guests