Monitoring stdout in (more or less) real time

ivanko.rus at gmail.com ivanko.rus at gmail.com
Sat Aug 29 02:28:26 EDT 2009


Hello to everyone! I am making a program that will be a GTK+ frontend to  
ffmpeg. Naturally, one of the main functions is parsing ffmpeg's output.  
It's pretty simple when I, for example, retrieve information about a file  
(the program finishes and I read the output). But it also needs to parse  
working ffmpeg's output (in order to retrieve the percentage, remaining  
time, etc.). So, actually what I do is Popen ffmpeg, and connect to its  
stdout. And as stdout is represented by a file object, it needs to be  
read(). The problem is that read() reads until EOF is reached, which  
doesn't exist while the program is running (the same goes with  
communicate()).
So my question is: is there a way to retrieve the stdout without waiting  
the program to finish?

PS. I think it might be redirected to a "normal", existing file, but may be  
there are more optimal ways.

I will be grateful for any answer! And sorry for my English =)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090829/9bed8b82/attachment.html>


More information about the Python-list mailing list