views:

48

answers:

2

I can call FFmpeg with subprocess.Popen and retrieve the data I need, as it occurs (to get progress), but only in console. I've looked around and seen that you can't get the data "live" when running with pythonw. Yet, waiting until the process finishes to retrieve the data is moot, since I'm trying to wrap a PyQT GUI around FFmpeg so I can have pretty progress bars and whatnot. So the question is, can you retrieve "live" data from a subprocess call when using pythonw?

I haven't tried simply compiling the application with py2exe yet as a windows application, would that fix the problem?

A: 

In your call to subprocess.Popen, use stdout=subprocess.PIPE. Then you will be able to read from the process's .stdout.

Daniel Stutzbach
+1  A: 
process = subprocess.Popen(your_cmd, shell=true, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

count=0    
while True:
    buff = process.stdout.readline()

    if buff == '':    
        count += 1

    if buff == '' and process.poll() != None: 
        break

    sys.stdout.write(buff)

process.wait()
zhongshu
This fixed the issue. I was actually using ALMOST the exact same code, however, I wasn't grabbing the stderr, thus it was giving me the Invalid Header issue. Upon adding the stderr in, it worked. Thanks!
Cryptite