First commit

This commit is contained in:
Blue Fox 2022-12-29 09:34:05 +01:00
commit c2361ac703
4 changed files with 213 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
# IDE files
.idea/

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 KiB

62
program.py Normal file
View File

@ -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_()

149
userinterface.ui Normal file
View File

@ -0,0 +1,149 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>747</width>
<height>318</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="titleLabel">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:18pt; font-weight:600; color:#8ae234;&quot;&gt;FFmpeg &lt;/span&gt;&lt;span style=&quot; font-size:18pt; font-weight:600; color:#729fcf;&quot;&gt;video converter&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="dragL">
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="text">
<string>Drag your file here</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout"/>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QPushButton" name="fileInputBtn">
<property name="text">
<string>Get Input File</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="OutputTypeCB">
<item>
<property name="text">
<string>Output type</string>
</property>
</item>
<item>
<property name="text">
<string>mov</string>
</property>
</item>
<item>
<property name="text">
<string>webm</string>
</property>
</item>
<item>
<property name="text">
<string>mp4</string>
</property>
</item>
<item>
<property name="text">
<string>mkv</string>
</property>
</item>
<item>
<property name="text">
<string>mpg</string>
</property>
</item>
<item>
<property name="text">
<string>mp3</string>
</property>
</item>
<item>
<property name="text">
<string>m4a</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLineEdit" name="outputFileNameLE">
<property name="placeholderText">
<string>Output filename (without extension)</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="convertBtn">
<property name="text">
<string>Convert!</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QProgressBar" name="convertPB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="cursor">
<cursorShape>WaitCursor</cursorShape>
</property>
<property name="toolTipDuration">
<number>4</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="textVisible">
<bool>true</bool>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="invertedAppearance">
<bool>false</bool>
</property>
<property name="textDirection">
<enum>QProgressBar::TopToBottom</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>