VLC and Python troubles! Help!

This forum is about all development around libVLC.
middo
New Cone
New Cone
Posts: 1
Joined: 17 Jul 2010 01:00

VLC and Python troubles! Help!

Postby middo » 17 Jul 2010 01:08

Hello, I had no idea where to post this since there are no other scripting related sections except the explicitly Lua one and the explicitly browser plugin one.

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
The important line is :

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')
Here's my script. It's really basic, it sets up playback instance and creates media with some options. Except that it seems to ignore the options and just use the defaults for dshow:// (ie: playing back the webcam input and audio, when it shouldnt be showing me any video and just playback & stream the audio).

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
So to summarize: the line of code that creates the media player doesn't seem to be eating my options, or I'm doing it all wrong. Please advise.

I'm aware that there's not a huge community surround python support here so maybe I'm missing something.

OlivierAubert
Developer
Developer
Posts: 92
Joined: 08 Mar 2007 15:43

Re: VLC and Python troubles! Help!

Postby OlivierAubert » 19 Jul 2010 11:35

Hello

The media option setting code you mention actually works. You can try the simple example mentioned in the docstring:

i = vlc.Instance()
p = i.media_player_new()
m=i.media_new('foo.avi', 'sub-filter=marq{marquee=Hello}')
p.set_media(m)
p.play()

or the shorter and more pythonic equivalent:

p = vlc.MediaPlayer()
p.set_mrl('foo.avi', 'sub-filter=marq{marquee=Hello}')
p.play()

and you should see the marquee string displayed. In this case, you will have to look somewhere else (and maybe not even in the python code itself) for the error.

cen
New Cone
New Cone
Posts: 9
Joined: 13 Jan 2014 12:17

Re: VLC and Python troubles! Help!

Postby cen » 26 Jan 2014 20:33

Hello,
the command line option works
vlc foo.avi --sub-filter=marq{marquee=Hello}
but the two short examples doesn't.

Do you have any idea?
I'm using
2.2.0-git Weatherwax
vlc.py build_date = "Tue Jul 2 10:35:53 2013"

OlivierAubert
Developer
Developer
Posts: 92
Joined: 08 Mar 2007 15:43

Re: VLC and Python troubles! Help!

Postby OlivierAubert » 06 Feb 2014 22:29

See https://forum.videolan.org/viewtopic.ph ... on#p354390 : since 2012 and some pipeline changes, the marquee filter cannot be set on invidual media items, it has to be set on the whole VLC instance.

hakao
New Cone
New Cone
Posts: 2
Joined: 18 Mar 2021 20:13

Re: VLC and Python troubles! Help!

Postby hakao » 18 Mar 2021 21:17

Is there any one makes this stream running?


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 20 guests