我需要一种方法来知道ffmpeg何时完成了它的工作。下面是我的代码:
def on_button_clicked(self, button, progress_bar, filename):
self.execute(progress_bar, filename)
progress_bar.set_text('Encoding')
progress_bar.pulse()
def execute(self, progress_bar, filename):
cmd = ['ffmpeg', '-y',
'-i', filename,
'-r', '30',
'/tmp/test-encode.mkv']
process = sp.Popen(cmd, stdin=open(os.devnull))
progress_bar.set_text('Done')
"完成"永远不会出现。不过,任务已经完成了。我可以在shell窗口中看到ffmpeg已经完成。我怎样才能得到信号?
尝试强制GTK处理set_text:
之后的挂起事件## force the refresh of the screen
while gtk.events_pending():
gtk.main_iteration()
我是这样做的:
p = sp.Popen(command, stdin=sp.PIPE, stdout=sp.PIPE, stderr=sp.PIPE)
def mycallback(p):
p.poll()
if p.returncode is None:
# Waiting for Godot
return True
else:
# Yay, wait is over!
return False
GObject.timeout_add(1000, mycallback, p)