[solved] Python: Parameter format for "libvlc_video_set_aspect_ratio"
Posted: 28 Apr 2019 07:07
by Domarius
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"
Re: [solved] Python: Parameter format for "libvlc_video_set_aspect_ratio"
Posted: 29 Apr 2019 01:35
by Domarius
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...
Re: [solved] Python: Parameter format for "libvlc_video_set_aspect_ratio"
Posted: 29 Apr 2019 15:06
by chubinou
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") ?
Re: [solved] Python: Parameter format for "libvlc_video_set_aspect_ratio"
Posted: 30 Apr 2019 01:17
by Domarius
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.
Re: [solved] Python: Parameter format for "libvlc_video_set_aspect_ratio"
Posted: 01 May 2019 01:00
by Domarius
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