63 lines
2.2 KiB
Python
63 lines
2.2 KiB
Python
import os
|
||
import re
|
||
from PyQt5 import QtWidgets, uic, QtCore
|
||
import sys
|
||
from PyQt5.QtGui import QIcon
|
||
import ffmpeg
|
||
from PyQt5.QtWidgets import QFileDialog
|
||
|
||
|
||
class Ui(QtWidgets.QWidget):
|
||
def __init__(self):
|
||
super(Ui, self).__init__()
|
||
uic.loadUi('userinterface.ui', self)
|
||
|
||
self.file_path = ""
|
||
|
||
self.setWindowIcon(QIcon('icon.png'))
|
||
self.setWindowTitle("Videoconverter")
|
||
self.setStyleSheet("background-color:#3D3D3D;")
|
||
self.convertPB.hide()
|
||
|
||
|
||
def onConvertBtnClicked():
|
||
self.convertPB.hide()
|
||
self.setCursor(QtCore.Qt.WaitCursor)
|
||
#self.setEnabled(False)
|
||
file_folder = re.split(os.sep, self.file_path[::-1])
|
||
file_folder.pop(0)
|
||
file_folder = "/".join(file_folder)
|
||
file_folder = file_folder[::-1]
|
||
if str(self.OutputTypeCB.currentText()) != "Output type":
|
||
ffmpeg.input(self.file_path).output(file_folder + os.sep + str(self.outputFileNameLE.text()) + "." + str(self.OutputTypeCB.currentText())).run()
|
||
else:
|
||
print("CHOOSE AN OUTPUT TYPE!\n\n")
|
||
self.setEnabled(True)
|
||
self.fileInputBtn.setEnabled(True)
|
||
self.setCursor(QtCore.Qt.ArrowCursor)
|
||
|
||
|
||
def onFileInputBtnClicked():
|
||
fileDialog = QFileDialog()
|
||
self.file_path, _ = fileDialog.getOpenFileName(self, "Open Media File", os.environ['HOME'] + os.sep + "Videos", "*.webm *.mp4 *.mkv *.mpg *.mpeg *.mp3 *.m4a *.wav")
|
||
#self.file_path = fileDialog.getExistingDirectory(self)
|
||
print(self.file_path)
|
||
filename = re.split(os.sep, self.file_path[::-1])
|
||
filename = filename[0][::]
|
||
filename = filename[::-1]
|
||
self.fileInputBtn.setText("Get Input File – " + filename)
|
||
#self.fileInputBtn.setEnabled(False)
|
||
|
||
self.convertBtn.clicked.connect(onConvertBtnClicked)
|
||
self.fileInputBtn.clicked.connect(onFileInputBtnClicked)
|
||
|
||
self.dragL.dragEnterEvent = lambda e: print(e.mimeData().data())
|
||
self.dragL.dropEvent = lambda e: print(self.dragL.setText(e.mimeData().data()))
|
||
self.dragL.hide()
|
||
|
||
self.show()
|
||
|
||
app = QtWidgets.QApplication(sys.argv)
|
||
window = Ui()
|
||
app.exec_()
|