2

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

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)

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: 1280x720@25.00 interlace:0 deinterlace:0 anaglyph:0 par:1.00 layer:0 alpha:255

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?

Thanks

#!/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()
Vinz
  • 5,997
  • 1
  • 31
  • 52
Oktay S
  • 21
  • 2
  • do you want to get the messages while the process is still running? If you run it in a terminal as `omxplayer $url |& cat`; do you see the messages in 5-7 seconds (before `omxplayer` exits)? See [Python subprocess readlines() hangs](http://stackoverflow.com/q/12419198/4279) – jfs Aug 21 '15 at 15:32

1 Answers1

2

try this:

proc=Popen(['omxplayer',url], stdout=PIPE, stderr=PIPE)
print proc.communicate()   # remove [0]
scytale
  • 12,346
  • 3
  • 32
  • 46
  • I already try but, nothing change i did not get second part of omxplayer terminal message. – Oktay S Aug 19 '15 at 18:47
  • please see my updated code. you need to read the docs for the subprocess module to understand how stdout and stderr are handled – scytale Aug 20 '15 at 10:10