15

I want to use vlc.py to play mpeg2 stream http://wiki.videolan.org/Python_bindings.

There are some examples here: http://git.videolan.org/?p=vlc/bindings/python.git;a=tree;f=examples;hb=HEAD

When I run the examples, it just can play video file, I want to know is there any examples to play video stream ?

why
  • 23,923
  • 29
  • 97
  • 142

3 Answers3

6

According to this Pastebin entry, linked to in this mailing list, it can be solved using a method like this:

import vlc
i = vlc.Instance('--verbose 2'.split())
p = i.media_player_new()
p.set_mrl('rtp://@224.1.1.1')
p.play()

I haven't tried it though, so please let me know if it works.

Steinar Lima
  • 7,644
  • 2
  • 39
  • 40
3

This is a bare bones solution:

import vlc
Instance = vlc.Instance()
player = Instance.media_player_new()
Media = Instance.media_new('http://localhost/postcard/GWPE.avi')
Media.get_mrl()
player.set_media(Media)
player.play()

if the media is a local file you will have to alter:

Media = Instance.media_new('http://localhost/postcard/GWPE.avi')
Media.get_mrl()

to:

Media = Instance.media_new_path('/path/to_your/file/filename.avi')

note that you must lose the get_mrl() as well as changing the function.

Rolf of Saxony
  • 21,661
  • 5
  • 39
  • 60
1
import vlc
vlcInstance = vlc.Instance()
player = vlcInstance.media_player_new()
player.set_mrl("rtsp://URL_PATH")
player.play()

I was able to open a stream with the following code, combining the previous answers. Tested this with a network webcam

hoffmanuel
  • 403
  • 1
  • 5
  • 14