[solved] Python: Parameter format for "libvlc_video_set_aspect_ratio"

This forum is about all development around libVLC.
Domarius
Blank Cone
Blank Cone
Posts: 17
Joined: 28 Apr 2017 22:22

[solved] Python: Parameter format for "libvlc_video_set_aspect_ratio"

Postby Domarius » 28 Apr 2019 07:07

I'm using the vlc.py Python wrapper, and I can't work out what format the parameters need to be in when calling "libvlc_video_set_aspect_ratio"

vlc.libvlc_video_set_aspect_ratio(player, "16:9")
Gives the error;
ctypes.ArgumentError: argument 2: <class 'TypeError'>: wrong type

vlc.libvlc_video_set_aspect_ratio(player, c_char_p('16:9'))
Gives the error;
"builtins.TypeError: bytes or integer address expected instead of str instance"

Domarius
Blank Cone
Blank Cone
Posts: 17
Joined: 28 Apr 2017 22:22

Re: [solved] Python: Parameter format for "libvlc_video_set_aspect_ratio"

Postby Domarius » 29 Apr 2019 01:35

I asked here and got an answer :)
https://python-forum.io/Thread-Can-t-wo ... 8#pid78868

The correct way is:
player.video_set_aspect_ratio('16:9')

I'm still confused vlc.libvlc_video_set_aspect_ratio(player, '16:9') doesn't work, but player.video_set_aspect_ratio('16:9') does. Clearly, they're different function calls, yes, but it seems to me they should behave the same...

chubinou
Developer
Developer
Posts: 521
Joined: 23 Jul 2015 15:19

Re: [solved] Python: Parameter format for "libvlc_video_set_aspect_ratio"

Postby chubinou » 29 Apr 2019 15:06

Hi,

your error message state that it expect bytes rather that str,

can you try vlc.libvlc_video_set_aspect_ratio(player, b"16:9") ?

Domarius
Blank Cone
Blank Cone
Posts: 17
Joined: 28 Apr 2017 22:22

Re: [solved] Python: Parameter format for "libvlc_video_set_aspect_ratio"

Postby Domarius » 30 Apr 2019 01:17

That worked as well! Thanks. So that uncovers some of the mystery about what was wrong with the long version.

Can you tell me, looking at the API docs,https://www.olivieraubert.net/vlc/python-ctypes/doc/ how I was supposed to discover the "player.video_set_aspect_ratio('16:9')" version of the same command, and why it doesn't need the byte version of the string; b"16:9"?

I would like to get better at navigating the API docs and solving these problems myself.

Domarius
Blank Cone
Blank Cone
Posts: 17
Joined: 28 Apr 2017 22:22

Re: [solved] Python: Parameter format for "libvlc_video_set_aspect_ratio"

Postby Domarius » 01 May 2019 01:00

Ah, I see, it's under the MediaPlayer object, which is what's returned when you call vlcInstance.media_player_new()
https://www.olivieraubert.net/vlc/pytho ... class.html


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 7 guests