Skip to content

Commit

Permalink
Merge pull request #36 from kanehekili/branch/qt6
Browse files Browse the repository at this point in the history
Branch/qt6
  • Loading branch information
kanehekili authored May 7, 2024
2 parents 684bebf + f17c750 commit bae642b
Show file tree
Hide file tree
Showing 25 changed files with 8,752 additions and 147 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.project
/.pydevproject
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,29 @@ Reencoding is possible for exact cutting as well as converting to different cont

VideoCut supports the cutting of subtitles when "Show subtitles" in the settings dialog is enabled. This flag will display the "first" subtitles stream and will cut all subtitles that have been defined in the "language" dialog.

The current version is written in python3 and uses the qt5 widget kit.
The current version is written in python3 and uses the qt6 widget kit.

### Prerequisites
* Arch: python3, python-pillow and mpv
* Debian/Mint/Ubuntu: python3 python3-pil libmpv1 python3-pyqt5.qtopengl (no-recommends)
* Debian/Mint/Ubuntu: python3 python3-pil libmpv1 (no-recommends)
#not working for Ubuntu 18.4: libmpv - use python3-opencv instead
* Fedora: python3-pillow-qt and mpv-libs.x86_64
* ffmpeg > 3.X to 5.X
* python3-pyqt5
* ffmpeg > 3.X to 6.X
* python3-pyqt6
* optional:(legacy) OpenCV 2.4 up to OpenCV 4.x (must be build with ffmpeg - with all its dependencies)

#### Set GTK Theme for this QT application
If you are running a DE with GTK/Gnome (as opposed to LXQT or KDE) you need to tweak your system:
(Arch users may have to install qt5-styleplugins from AUR)
* Arch users may have to install qt6-styleplugins from AUR
* Ubuntu/Debian users will not get a uniform look GTK theme for QT anymore. (qt5 was the last)

`sudo nano /etc/environment`

add the follwing line:

`QT_QPA_PLATFORMTHEME=gtk2`
`QT_QPA_PLATFORMTHEME=gtk2` or

`QT_QPA_PLATFORMTHEME=qt6c` (if qt6c is installed)

and logout/login (or reboot)

Expand Down Expand Up @@ -117,22 +120,22 @@ Remove with:
* Download [PKGBUILD ](https://aur.archlinux.org/cgit/aur.git/snapshot/videocut.tar.gz)
* unpack it and go into the "videocut" folder
* execute `makepkg -s`
* excute `sudo pacman -U videocut-2.x.x.x-1-x86_64.pkg.tar.zst`
* excute `sudo pacman -U videocut-3.x.x.x-1-x86_64.pkg.tar.zst`
* uninstall via `sudo pacman -Rs videocut`

Select video and open it with "Open with ->VideoCut", oder via terminal "VideoCut"


#### Install dependencies manually on Linux Mint or Ubuntu (tested from 20.04 to 22.04)
```
sudo apt –no-install-recommends install python3-pyqt5 ffmpeg python3-pil python3-pyqt5.qtopengl libmpv1
sudo apt –no-install-recommends install python3-pyqt6 ffmpeg python3-pil libmpv2
```
libmpv1 won't work on Ubuntu 18.04 - no bindings for the old libs - use opencv instead
For Ubuntu 23.04 or Debian 12 and newer libmpv2 should be used.

#### Install dependencies on Fedora
```
sudo dnf python3-qt5 ffmpeg python3-pillow-qt mpv-libs.x86_64
sudo dnf python3-qt6 ffmpeg python3-pillow-qt mpv-libs.x86_64
```

### How to install with a terminal
Expand All @@ -145,7 +148,7 @@ sudo dnf python3-qt5 ffmpeg python3-pillow-qt mpv-libs.x86_64
* The app should be appear in a menu or "Actvities"
* Can be openend by selecting a video file & Open with...
* In the terminal can be started via `videocut`
* python qt5, mpv and ffmpeg are required
* python qt6, mpv and ffmpeg are required
* you may now remove that download directory.
* logs can be found in the user home ".config/VideoCut" folder

Expand Down Expand Up @@ -174,6 +177,10 @@ Copy the .desktop file and change the exec line to "Exec= python3 .../VideoCut.p
Opencv will not be displaying subtitles nor frametypes.

### Changes
07.05.2024
* Switch to pyqt6.
* Adaption to mpv 0.38

28.03.2023
* Fix for target extension based on the codecs
* Added audio mute - idea by user ![RedFraction](https://github.com/RedFraction)
Expand Down
2 changes: 1 addition & 1 deletion build/AUR-template/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pkgrel=@xpkgrelx@
pkgdesc="Fast mp4/matroska/Av1/webm/mp2/mpts lossless Video cutter"
url="https://github.com/kanehekili/VideoCut"
license=('GPL2')
depends=('python-pyqt5' 'mpv' 'ffmpeg' 'python-pillow')
depends=('python-pyqt6' 'mpv' 'ffmpeg' 'python-pillow')
arch=('x86_64')
source=(https://github.com/kanehekili/VideoCut/releases/download/@xxx@/videocut@[email protected])
md5sums=(@md5sum@)
Expand Down
2 changes: 1 addition & 1 deletion build/DEB-template/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Maintainer: kanehekili <[email protected]>
Section: video
Priority: optional
Build-Depends: debhelper, libc6-dev, libavcodec-dev, libavformat-dev
Standards-Version: 2.0.0
Standards-Version: 3.0.0



Expand Down
4 changes: 2 additions & 2 deletions build/DEB-template/debian/copyright
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: videocut
Upstream-Contact: kanehekili, <mat.wegmann@gmail.com>
Upstream-Contact: kanehekili, <kanehekili.media@gmail.com>

Files: *
Copyright: 2022, kanehekili, <mat.wegmann@gmail.com>
Copyright: 2024, kanehekili, <kanehekili.media@gmail.com>
License: GPL-2+ and MIT
Full text of licence can be found in /usr/share/common-licenses

6 changes: 3 additions & 3 deletions build/build.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version=2.2.1
version=3.0.0
ubu0=focal
ubu1=jammy
ubu2=lunar
pkgrelease=3
ubu2=noble
pkgrelease=2
2 changes: 1 addition & 1 deletion build/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
<filter token="xxx" value="${version}"/>
<filter token="xpkgrelx" value="${pkgrelease}"/>
<filter token="xtsx" value="${time.stamp}"/>
<filter token="xlibsx" value="python3, ffmpeg, python3-pyqt5, python3-pil, qt5-style-plugins, libmpv2, python3-pyqt5.qtopengl"/>
<filter token="xlibsx" value="python3, ffmpeg, python3-pyqt6, python3-pil,libmpv2"/>
</filterset>

</copy>
Expand Down
4 changes: 2 additions & 2 deletions build/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ sudo ln -s /opt/videocut/VideoCut.py /usr/bin/VideoCut

echo "######################################################################"
echo "# Ensure you have installed: #"
echo "# debian/ubuntu/mint: python3-pyqt5 ffmpeg python3-pil libmpv1 #"
echo "# arch &derivates: python-pyqt5 ffmpeg python-pillow mpv #"
echo "# debian/ubuntu/mint: python3-pyqt6 ffmpeg python3-pil libmpv1 #"
echo "# arch &derivates: python-pyqt6 ffmpeg python-pillow mpv #"
echo "######################################################################"

echo "App installed."
6 changes: 5 additions & 1 deletion src/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/FFMPEGTools.pyc
/VideoCut.py.old
/Configuration.py
/__pycache__/
__pycache__/
/VideoCut.log
*.pyc
.project
.pydevproject

12 changes: 6 additions & 6 deletions src/CvPlayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
@author: kanehekili
'''

from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import pyqtSignal
from PyQt5 import QtWidgets,QtGui,QtCore
from PyQt6.QtWidgets import QApplication
from PyQt6.QtCore import pyqtSignal
from PyQt6 import QtWidgets,QtGui,QtCore
import sys
from datetime import timedelta
import FFMPEGTools
Expand Down Expand Up @@ -145,7 +145,7 @@ def __init__(self, numpyArray):
bytesPerLine = bytesPerComponent * width

OPENCV.setColor(dst)
super(CVImage, self).__init__(dst.data, width, height, bytesPerLine, QtGui.QImage.Format_RGB888)
super(CVImage, self).__init__(dst.data, width, height, bytesPerLine, QtGui.QImage.Format.Format_RGB888)

def getRotation(self):
#seems to be fixed in opencv 4.5...
Expand All @@ -160,10 +160,10 @@ def __init__(self, parent):
QtWidgets.QFrame.__init__(self, parent)
self._defaultHeight = 576
self._defaultWidth = 720
self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
self.setSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding)
self._image = None
self.imageRatio = 16.0 / 9.0
self.setFrameStyle(QtWidgets.QFrame.Panel | QtWidgets.QFrame.Sunken)
self.setFrameStyle(QtWidgets.QFrame.Shape.Panel | QtWidgets.QFrame.Shadow.Sunken)
self.setLineWidth(1)

def paintEvent(self, event):
Expand Down
28 changes: 16 additions & 12 deletions src/MpvPlayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,28 @@
GNU Affero General Public License v3.0
'''

from PyQt5.QtCore import Qt,QMetaObject,pyqtSlot,pyqtSignal
from PyQt5 import QtCore,QtWidgets
from PyQt5 import QtGui
from PyQt6.QtCore import Qt,QMetaObject,pyqtSlot,pyqtSignal, QByteArray
from PyQt6 import QtCore,QtWidgets
from PyQt6 import QtGui
from PyQt6.QtOpenGLWidgets import QOpenGLWidget

from threading import Condition
import FFMPEGTools
import time,re
import locale

from lib.mpv import (MPV,MpvGlGetProcAddressFn,MpvRenderContext)

from PyQt5.QtOpenGL import QGLContext
from lib.mpv import (MPV,MpvGlGetProcAddressFn,MpvRenderContext,MpvEventEndFile)


Log=FFMPEGTools.Log

def get_proc_addr(_, name):
glctx = QGLContext.currentContext()
glctx = QtGui.QOpenGLContext.currentContext()
if glctx is None:
return 0
addr = int(glctx.getProcAddress(name.decode('utf-8')))
qb = QByteArray(name)
addr = int(glctx.getProcAddress(qb))
return addr


Expand All @@ -50,11 +51,13 @@ def sizeHint(self):
def updateUI(self,frameNumber,framecount,timeinfo):
self.trigger.emit(frameNumber,framecount,timeinfo)

class VideoGLWidget(QtWidgets.QOpenGLWidget):
class VideoGLWidget(QOpenGLWidget):
trigger = pyqtSignal(float,float,float)

def __init__(self, parent,mpv):
QtWidgets.QOpenGLWidget.__init__(self, parent)
QOpenGLWidget.__init__(self,parent)
#setSurfaceType(QWindow.OpenGLSurface)
#QOpenGLWindow.__init__(self)
self.ratio= 1.0 #?is that true?
self.mpv=mpv
self.ctx = None
Expand Down Expand Up @@ -152,6 +155,7 @@ def initGLPlayer(self):
'''
def __baseMpvArgs(self):
return { "hwdec":"auto-safe",
"vo":"libmpv",
#video_sync="display-desync", #no effect on mkv/vc1
"log_handler":self._passLog,
"loglevel" : 'error',
Expand Down Expand Up @@ -261,7 +265,6 @@ def open(self,filePath):
self._getReady()
except Exception as ex:
Log.exception("Open mpv file")
print(ex)

#Test, not activated
def _oncallback(self,callback):
Expand Down Expand Up @@ -366,7 +369,8 @@ def takeScreenShot(self,path):
return True

def _onPropertyChange(self,name,pos):
print(" >",name,":",pos)
pass
#print(" >",name,":",pos)

def _onDuration(self,name,val):
if val is not None:
Expand Down Expand Up @@ -616,7 +620,7 @@ def info(self):

def _makeThumbnail(self,qImage):
pix = QtGui.QPixmap.fromImage(qImage)
pix = pix.scaledToWidth(self.iconSize, mode=Qt.SmoothTransformation)
pix = pix.scaledToWidth(self.iconSize, mode=Qt.TransformationMode.SmoothTransformation)
return pix

def _sanityCheck(self,streamData):
Expand Down
Loading

0 comments on commit bae642b

Please sign in to comment.