vlc.py如何播放视频流?

发布于 2025-01-07 17:18:49 字数 389 浏览 1 评论 0原文

我想使用 vlc.py 播放 mpeg2 流 http://wiki.videolan.org/Python_bindings

这里有一些示例: http://git.videolan.org/?p=vlc/bindings/python.git;a=tree;f=examples;hb=HEAD

当我运行示例时,它只能播放视频文件,我想知道有没有例子可以玩视频流?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

寄与心 2025-01-14 17:18:49

根据 this Pastebin 条目,链接到 这个邮件列表,可以用这样的方法解决:

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

我没有尝试过不过,请告诉我它是否有效。

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.

如梦初醒的夏天 2025-01-14 17:18:49

这是一个简单的解决方案:

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()

如果媒体是本地文件,您将必须更改:

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

为:

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

请注意,您必须丢失 get_mrl() 以及更改函数。

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.

神也荒唐 2025-01-14 17:18:49
import vlc
vlcInstance = vlc.Instance()
player = vlcInstance.media_player_new()
player.set_mrl("rtsp://URL_PATH")
player.play()

我能够使用以下代码打开一个流,并结合前面的答案。
使用网络摄像头对此进行了测试

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文