在终端中使用vlc时出现打开url错误

2024-04-19 19:04:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我在linux终端上运行以下命令:

vlc http://streamx/live/....stream/playlist.m3u8 --rate=1 --video-filter=scene --vout=dummy --run-time=3 --scene-format=png --scene-ratio=24 --scene-path=/home/pi/Desktop vlc://quit

如果url没问题,它会从流中生成一些图片。我想知道命令是否成功运行。在

如果url不正确,则写出:

^{pr2}$

如果url正确,则写出:

[73b03f20] httplive stream: HTTP Live Streaming (streamx/live/....stream/playlist.m3u8)

在运行命令(例如在python脚本中)之后,如果url是否正常,如何获取?在

提前谢谢!在


Tags: 命令livehttp终端urlstreamratelinux
1条回答
网友
1楼 · 发布于 2024-04-19 19:04:26

我们需要检查两件事。在

  • 1) 如果URL本身是活动的
  • 2) 如果URL是活动的,则为数据流(您可能已断开链接)。在

1)检查URL是否有效。我们可以检查状态码。任何2xx或3xx都是好的(您可以根据您的需要定制)。在

import urllib
url = 'http://aska.ru-hoster.com:8053/autodj'

code = urllib.urlopen(url).getcode()
 if str(code).startswith('2') or str(code).startswith('3') :
    print 'Stream is working'
else:
    print 'Stream is dead'

2)现在我们有了好的URL,但我们需要检查我们是否有流媒体和链接没有死。
使用VLC,我们可以连接到站点,尝试在链接处播放媒体,然后检查错误。在

这是我从我的other帖子中得到的一个工作示例。在

^{pr2}$

相关问题 更多 >