In case you didn't know, VLC has pretty decent python support, a python/c interface is generated off the headers using ctypes which allows us to call/receive data pretty directly from the actual libvlc itself! Cool!
What I have no clue how to do is to make something very simple work:
I'm working on a script that lets me start an instance of vlc streaming my audio in from a specific sound card, through udp, to another computer over the internet. Currently we do it by hand through the UI and it's getting unreliable with the less techy-employees, so I opted to set up a script that turns on the stream on both end for X amount of minutes or hours then turns it back off. Logistics aside, I have hit a wall in my understanding of how this all works.
Code: Select all
import vlc
import sys
if __name__ == "__main__":
if sys.argv[1] == 'in' or sys.argv[1] == 'out':
instance=vlc.Instance()
media = 0;
if sys.argv[1] == 'out':
media=instance.media_new('dshow://','show-vdev=none','dshow-adev=Cirrus Logic HD Audio','dshow-caching=200',
'sout=#duplicate{dst=udp{dst=192.168.2.99:1234},dst=display}',
'no-sout-rtp-sap', 'no-sout-standard-sap', 'sout-keep')
#todo: set up the receiving end, 'in'
player=instance.media_player_new()
player.set_media(media)
player.play()
print 'Streaming...'
while True:
pass
Code: Select all
media=instance.media_new('dshow://','show-vdev=none','dshow-adev=Cirrus Logic HD Audio','dshow-caching=200',
'sout=#duplicate{dst=udp{dst=192.168.2.99:1234},dst=display}',
'no-sout-rtp-sap', 'no-sout-standard-sap', 'sout-keep')
I don't know if I'm doing this right, but here's what the generated interface has to say about the creation of new media:
Code: Select all
def media_new(self, mrl, *options):
"""Create an empty Media Player object
Options can be specified as supplementary string parameters, e.g.
m=i.media_new('foo.avi', 'sub-filter=marq{marquee=Hello}', 'vout-filter=invert')
"""
m=libvlc_media_new_location(self, mrl)
for o in options:
libvlc_media_add_option(m, o)
return m
I'm aware that there's not a huge community surround python support here so maybe I'm missing something.