[Tutor] Interacting with stderr

Crush crushed26 at gmail.com
Thu Aug 28 00:45:41 CEST 2014


Hello, it has been a while and I hope I am sending to the correct email. 

How would I go about running a conditional statement against the contents of stderr. For instance, if "blah blah blah" is in stderr do X, else do Y. 

CODE: SELECT ALL
 
#!/usr/bin/env python
import subprocess
from subprocess import PIPE
i = 0
while i < 10:
    p = subprocess.call("avconv -v verbose -re -analyzeduration 1000 -i http://localhost:6498/ms2/1382097438004/0MediaPlayer+0+/octoshape+hVV+octolive.americaone.com+V+aone+V+live+V+ONECONNXT_DEMO1_HD_flv/aoneliveONECONNXTDEMO1HDflv  -c:v rawvideo -c:a pcm_s16le -ar 48000 -f nut - | ./bmdplay -m 12 -f pipe:0", shell=True)
    i += 1
    if i == 10:
        print "Gave up"


The above code works and I get no tracebacks, however I need to add to it and check the contents of stderr. Avconv by default sends the audio and video to stdout, which then sends the signal to a capture card in the machine. Avconv is sending the status of the broadcasted signal i.e. frames, time, fps, etc. to stderr, which is displayed in the terminal. 

Bo 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140827/05ab01b4/attachment.html>


More information about the Tutor mailing list