dimanche 26 juin 2016

Python bindings for libVLC - cannot change audio output device


VLC 2.2.3, python-vlc 1.1.2.

I have a virtual audio output and am trying to get libVLC to output on it. So far, I can see the virtual output appearing in libVLC, but selecting it makes audio play on the default output (i.e. the speakers).

This is the relevant part of what I have:

self.Instance = vlc.Instance()
self.player = self.Instance.media_player_new()

devices = []
mods = self.player.audio_output_device_enum()

if mods:
    mod = mods
    while mod:
        mod = mod.contents
        devices.append(mod.device)
        mod = mod.next

vlc.libvlc_audio_output_device_list_release(mods)

# this is the part I change on each run of the code.
self.player.audio_output_device_set(None, devices[0]) 

I've run the code multiple times, changing the device ID as per the code comment. However, the output device doesn't actually change. This is a headache for two reasons:

1) audio_output_device_set() doesn't return anything. I can't tell if I'm actually accomplishing anything when I run this function. 2) I can't even run audio_output_device_get() to check if the set function is doing anything as this is only for libvlc 3. I would prefer for my program to work with 2.2.3.

So, what I did next was install VLC 3.0 and run the above code with it. Now, audio_output_device_get() works and I can see that the set function is actually changing the output device to the virtual output. But sound STILL plays on the speakers.

What's going on? How do I fix this?

I asked at the VLC forums and got a singularly unhelpful reply telling me to 'check logs and documentation'. That's it. I've been superglued to the rather lacking documentation to get this far. Even though I doubt it can help, I've decided to try logging. I thought it would be as simple as calling libvlc_log_set_file but it needs a libVLC file pointer, and I don't know how to create one with a name and mode as in Python.

tl;dr:

1) How do I successfully change the audio output device? 2) How do I set up maximum verbosity logging?


Aucun commentaire:

Enregistrer un commentaire