本文介绍了Python 与 omxplayer 通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道 omxplayer 什么时候开始播放直播链接.有时这需要 4-5 秒,有时需要 6-7 秒.

I want to know when omxplayer starts playing a live stream link.Some time this takes 4-5 second some times 6-7 second.

当我执行 os.system('omxplayer '+url) 时,我立即收到以下消息:

When I execute os.system('omxplayer '+url), I immediately get the following message:

no xset in (/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl)
which: no xrefresh in (/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl)

然后当直播开始时(5-7 秒后),我得到:

then when the live stream starts (after 5-7 second), I get:

Video codec omx-h264 width 1280 height 720 profile 578 fps 25.000000
Audio codec aac channels 2 samplerate 44100 bitspersample 16
Subtitle count: 0, state: off, index: 1, delay: 0
V:PortSettingsChanged: [email protected] interlace:0 deinterlace:0 anaglyph:0 par:1.00 layer:0 alpha:255

我正在尝试通过子进程获取第二条消息.但我从来没有得到它.我如何才能收到第二条消息,或者我如何知道 omxplayer 何时开始工作?

I am trying to get the second message via subprocess. But I never get it. How can I get the second message or how can I know when omxplayer start working?

谢谢

#!/usr/bin/python2

import sys, os, time
from subprocess import PIPE, Popen


url="http://livestreamlink.m3u8"


def Main():
    proc=Popen(['omxplayer',url], stdout=PIPE)
    time.sleep(5)
    print proc.communicate()[0]


if __name__ == "__main__":
    Main()

推荐答案

试试这个:

proc=Popen(['omxplayer',url], stdout=PIPE, stderr=PIPE)
print proc.communicate()   # remove [0]

这篇关于Python 与 omxplayer 通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 18:21