1

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?

Community
  • 1
  • 1
Cryptite
  • 1,426
  • 2
  • 28
  • 50
  • The question you've linked shows you how to use pipes with subprocesses -- have you tried that? What happened? – Katriel Aug 19 '10 at 12:52

2 Answers2

4
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()
martineau
  • 119,623
  • 25
  • 170
  • 301
zhongshu
  • 7,748
  • 8
  • 41
  • 54
  • 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 Aug 19 '10 at 14:41
0

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

Daniel Stutzbach
  • 74,198
  • 17
  • 88
  • 77