Skip to content

Instantly share code, notes, and snippets.

@amoh-godwin
Created March 12, 2022 16:31
Show Gist options
  • Save amoh-godwin/a409658e54a074c77da3bed148ea05ce to your computer and use it in GitHub Desktop.
Save amoh-godwin/a409658e54a074c77da3bed148ea05ce to your computer and use it in GitHub Desktop.
import os
import threading
from PyQt6.QtCore import QObject, pyqtSlot, pyqtSignal
from pyffmpeg import FFmpeg
class Converter(QObject):
def __init__(self, parent=None):
QObject.__init__(self)
convertCompleted = pyqtSignal(str, arguments=['convert'])
progressUpdated = pyqtSignal(int, arguments=['progress'])
@pyqtSlot(str)
def convert(self, input_file: str):
c_thread = threading.Thread(target=self._convert,
args=[input_file])
c_thread.daemon = True
c_thread.start()
def _convert(self, input_file: str):
print('Inside Convert function')
input_file = input_file.replace('file:///', '')
audio_name = os.path.splitext(input_file)[0] + '.mp3'
ff_obj = FFmpeg()
ff_obj.report_progress = True
ff_obj.onProgressChanged = self.updateProgress # line 30
ff_obj.convert(input_file, audio_name)
print('Done: ', audio_name)
self.convertCompleted.emit('')
def updateProgress(self, progress):
self.progressUpdated.emit(progress)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment