Python bindings - Streaming YouTube

This forum is about all development around libVLC.
rj540
New Cone
New Cone
Posts: 2
Joined: 26 Apr 2011 21:08

Python bindings - Streaming YouTube

Postby rj540 » 26 Apr 2011 21:21

Hello all!
I am trying to make a program that streams YouTube videos using VLC.
I know that the VLC standalone can do this using Open Network--> simple "youtube.com/watch?v=xxxxx" URL.

However, how can I accomplish this with Python bindings? When I try to use vlc.MediaPlayer() and I set the media (in various ways) to a YouTube URL, I can't get it to play, or tell me the title of the movie, which makes me think I need to open the stream in some way I'm not seeing.

How to stream YouTube with Python bindings?

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37519
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Python bindings - Streaming YouTube

Postby Jean-Baptiste Kempf » 26 Apr 2011 21:37

Do you have the logs?
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

rj540
New Cone
New Cone
Posts: 2
Joined: 26 Apr 2011 21:08

Re: Python bindings - Streaming YouTube

Postby rj540 » 26 Apr 2011 22:26

I'm sorry, but I'm a newb, and I can't seem to get a log intialized? If I'm supposed to enter a "cls" argument, I'm not sure what that would be.

>>> log=vlc.Log()

Traceback (most recent call last):
File "<pyshell#37>", line 1, in <module>
log=vlc.Log()
File "/Users/alexandria/Desktop/vlc.py", line 1286, in __new__
return _Constructor(cls, ptr)
File "/Users/alexandria/Desktop/vlc.py", line 150, in _Constructor
raise VLCException('(INTERNAL) ctypes class.')
VLCException: (INTERNAL) ctypes class.

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

Re: Python bindings - Streaming YouTube

Postby OlivierAubert » 28 Apr 2011 11:49

A Log class cannot be instanciated alone, a reference must be obtained through the Instance.log_open() method. Anyway, you do not need to mess with the log API. You can simply do

Code: Select all

i = vlc.Instance('--verbose 2'.split()) p = i.media_player_new() p.set_mrl('your_youtube_url') p.play()
and you will get log messages on stderr.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 2 guests