Windows下Python加载VLC的方法

 

Windows下Python加载VLC的方法

參考:https://blog.csdn.net/fleaxin/article/details/101943941

小結:

1. 使用pip install python-vlc, 記住vlc的版本,為下一步下載vlc的lib做準備;

2. 從http://download.videolan.org/pub/videolan/vlc/下載對應的文件,版本和第一步使用pip install的相同;

Sample code如下

import os
import vlc
import time


def get_player(url='rtsp://10.0.0.2/stream1'):
    Instance = vlc.Instance()
    player = Instance.media_player_new()
    Media = Instance.media_new(url)
    Media.get_mrl()
    player.set_media(Media)
    player.play()
    return player

if __name__ == '__main__':
    player = get_player()
    time.sleep(2)
    if player.is_playing():
        time.sleep(10)
        player.release()
    player.release()

 

你可能感兴趣的:(vlc)