Launch window when the process ends in ffmpeg. PyQt

1

In Python, PyQt and ffmpeg: I need to learn how to make a window appear with the typical message: "The process has finished" That window has to appear when the ffmpeg process ends. Ffmpeg launched it with subprocess. I can not know how to execute "something" when a process ends. This is my code (for now):

import sys
   from PyQt4.QtCore import *
   from PyQt4.QtGui import *
   import subprocess



   fileinput = ''

   def window():
      app = QApplication(sys.argv)
      win = QDialog()
      b1 = QPushButton(win)
      b1.setText("Select file")
      b1.move(50,20)
      b1.clicked.connect(b1_clicked)

      b2 = QPushButton(win)
      b2.setText("Output file")
      b2.move(50,50)
      b2.clicked.connect(b2_clicked)

      b3 = QPushButton(win)
      b3.setText("Encode!")
      b3.move(50,80)
      b3.clicked.connect(b3_clicked)

      win.setGeometry(100,100,200,200)
      win.setWindowTitle("Encoder")
      win.show()
      sys.exit(app.exec_())

   def b1_clicked():
      global fileinput
      fileinput = QFileDialog.getOpenFileName(None, "Selecciona archivo a convertir", "/home/salva", "video files (*.avi *.mkv *.mp4 *.mov *.mpg);; All files (*)")
      print (fileinput)


   def b2_clicked():
      filesaved = QFileDialog.getSaveFileName(None, "Archivo de salida", "/home/salva", "video files (*.avi *.mkv *.mp4 *.mov *.mpg);; All files (*)")
      print (filesaved)


   def b3_clicked():
       subprocess.call(['ffmpeg', '-i', fileinput, filesaved])


   if __name__ == '__main__':
      window()

EDIT:

To understand my problem better, I build a very simple code and try to pop-up but it does not work:

import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *


a = 20
if a == 20:
    print (a)
    QtGui.QMessageBox.information(self, "Información", "Se ha procesado {0}".format(a),QtGui.QMessageBox.Ok)

The error that gives me is this:

  

QtGui.QMessageBox.information (self, "Information", "Processed   {0} ". Format (a), QtGui.QMessageBox.Ok) NameError: name 'QtGui' is not   defined

EDITO II:

I have worked on a simpler and more customized code for what I am doing to find out how to launch a window when button 3 finishes its process. I've tried but it does not work for me. I have a main window: window and another one that has to appear when button 3 finishes its process: winok I need to close the window window and winok window appear at the end of the process button 3. Also know how to check the return value of button 3 (which will be what ffmpeg do in the future) and show error or success message . This is what I have for now oriented to solve the window:

import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *


def window():

   win = QDialog()

   b1 = QPushButton(win)
   b1.setText("Select file")
   b1.move(50,20)
   b1.clicked.connect(b1_clicked)

   b2 = QPushButton(win)
   b2.setText("Output file")
   b2.move(50,50)
   b2.clicked.connect(b2_clicked)

   b3 = QPushButton(win)
   b3.setText("Encode!")
   b3.move(50,80)
   b3.clicked.connect(b3_clicked)

   win.setGeometry(100,100,200,200)
   win.setWindowTitle("Encoder")
   win.show()
   sys.exit(app.exec_())

def b1_clicked():
    print('boton 1 pulsado')


def b2_clicked():
    print('boton 2 pulsado')


def b3_clicked():
   print ('boton 3 pulsado')
   winok()

if __name__ == '__main__':
    app = QApplication(sys.argv)
    window()


def winok():

    win = QDialog()

    b10 = QPushButton(win)
    b10.setText("Do another job?")
    b10.move(50,20)
    b10.clicked.connect(b10_clicked)

    b11 = QPushButton(win)
    b11.setText("Exit")
    b11.move(50,50)
    b11.clicked.connect(b11_clicked)

    win.setGeometry(100,100,300,100)
    win.setWindowTitle("Work completed. Oh Yeah!")
    win.show()
    sys.exit(app.exec_())

def b10_clicked():
    print ('Volviendo a codificar...')


def b11_clicked():
    exit()
    
asked by salvaestudio 10.05.2017 в 17:57
source

1 answer

1

The simplest thing I can think of is to use QMessageBox :

def b3_clicked():
    subprocess.call(['ffmpeg', '-i', fileinput, filesaved])
    QtGui.QMessageBox.information(self, "Información", "Se ha procesado {0}".format(fileinput),QtGui.QMessageBox.Ok)

The correct thing would actually be to verify the return value of the ffmpeg and to show error or success message, but the example that happened to you is easily adaptable

    
answered by 10.05.2017 в 21:55