commit c2361ac703f16e0617990045b2c03cfb6b358fe5 Author: Blue Fox Date: Thu Dec 29 09:34:05 2022 +0100 First commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6fcf43c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# IDE files +.idea/ diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..d15ebdc Binary files /dev/null and b/icon.png differ diff --git a/program.py b/program.py new file mode 100644 index 0000000..1aa8012 --- /dev/null +++ b/program.py @@ -0,0 +1,62 @@ +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_() diff --git a/userinterface.ui b/userinterface.ui new file mode 100644 index 0000000..c863ab6 --- /dev/null +++ b/userinterface.ui @@ -0,0 +1,149 @@ + + + Form + + + + 0 + 0 + 747 + 318 + + + + Form + + + + + + <html><head/><body><p align="center"><span style=" font-size:18pt; font-weight:600; color:#8ae234;">FFmpeg </span><span style=" font-size:18pt; font-weight:600; color:#729fcf;">video converter</span></p></body></html> + + + + + + + + + + + true + + + QFrame::Box + + + Drag your file here + + + + + + + + + + + + Get Input File + + + + + + + + Output type + + + + + mov + + + + + webm + + + + + mp4 + + + + + mkv + + + + + mpg + + + + + mp3 + + + + + m4a + + + + + + + + Output filename (without extension) + + + + + + + Convert! + + + + + + + + + + + true + + + WaitCursor + + + 4 + + + 0 + + + true + + + Qt::Horizontal + + + false + + + QProgressBar::TopToBottom + + + + + + + + + +