how to import vlc plugins in to python script

你离开我真会死。 提交于 2019-12-13 00:46:00

问题


I'm trying to play the video using libvlc with python script, for that i got one script in the stack overflow post.

the script is follows:

 import os
 import sys
 import vlc

  if __name__ == '__main__':
#filepath = <either-some-url-or-local-path>
movie = os.path.expanduser(filepath)
if 'http://' not in filepath:
    if not os.access(movie, os.R_OK):
        print ( 'Error: %s file is not readable' % movie )
        sys.exit(1)
instance = vlc.Instance("--sout=#duplicate{dst=file{dst=example.mpg},dst=display}")
try:
    media = instance.media_new(movie)
except NameError:
    print ('NameError: % (%s vs Libvlc %s)' % (sys.exc_info()[1],
                   vlc.__version__, vlc.libvlc_get_version()))
    sys.exit(1)
player = instance.media_player_new()
player.set_media(media)
player.play()

#dont exit!
while(1):
    continue

when i run this code, i'm getting the eror like:

    Traceback (most recent call last):
    File "test1.py", line 3, in <module>
    import vlc
    ImportError: No module named vlc

How to import the vlc bindings in to the mechine, can any please help me...


回答1:


According to Python bindings VLC documentation:

You can download the vlc.py module from the Git repository. It only depends on ctypes (standard module in python >= 2.5). Put the module in some place accessible by python (either next to your application, or in a directory from sys.path).



来源:https://stackoverflow.com/questions/34669571/how-to-import-vlc-plugins-in-to-python-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!