Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
VideoService.probe() blackdetect argument added with preliminary ffpr…
…obe cmd syntax
  • Loading branch information
ozmartian committed Feb 12, 2018
1 parent eebbe23 commit d8d1a72
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 21 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG
@@ -1,5 +1,15 @@
vidcutter (5.5.0-1) stable; urgency=medium

* BUGFIXES (these are minor point release changes usually attributed to bugs
that are more regressions from previous versions (i.e. things no longer
behaving as they used to/should):

- selected region on slider not updating w/ main GUI thread resulting in it
disappearing shortly after being painted. FIXED

- SmartCut processing breaking on final join step causing SmartCut to remain
at 80% completion indefinitely. FIXED

* The most requested feature is finally added; media stream configuration! A
new media stream button has been added and enabled for use when
clips are all derived from the same source media OR media files added
Expand Down
@@ -1,8 +1,8 @@
#!/bin/bash

cd ..
cd ../..
rm -rf build dist vidcutter.egg-info
python3 setup.py bdist_wheel sdist
python3 setup.py bdist_egg sdist

read -e -p "Upload to PyPi? [y/n] " choice
[[ "$choice" == [Yy]* ]] && twine upload dist/*
37 changes: 21 additions & 16 deletions vidcutter/libs/videoservice.py
Expand Up @@ -42,9 +42,9 @@

try:
# noinspection PyPackageRequirements
import simplejson as json
from simplejson import loads, JSONDecodeError
except ImportError:
import json
from json import loads, JSONDecodeError


class VideoService(QObject):
Expand Down Expand Up @@ -85,7 +85,7 @@ def __init__(self, settings: QSettings, parent=None):
def setMedia(self, source: str) -> None:
try:
self.source = source
self.probe(source)
self.media = self.probe(source)
if self.media is not None:
if getattr(self.parent, 'verboseLogs', False):
self.logger.info(self.media)
Expand Down Expand Up @@ -117,11 +117,11 @@ def findBackends(settings: QSettings) -> Munch:
if path is None or not len(path):
for exe in VideoService.config.binaries[os.name][tool]:
if VideoService.frozen:
binpath = os.path.join(VideoService.getAppPath(), 'bin', exe)
binpath = VideoService.getAppPath(os.path.join('bin', exe))
else:
binpath = QStandardPaths.findExecutable(exe)
if not len(binpath):
binpath = QStandardPaths.findExecutable(exe, [os.path.join(VideoService.getAppPath(), 'bin')])
binpath = QStandardPaths.findExecutable(exe, [VideoService.getAppPath('bin')])
if os.path.isfile(binpath) and os.access(binpath, os.X_OK):
tools[tool] = binpath
if not VideoService.frozen:
Expand All @@ -148,7 +148,7 @@ def initProc(program: str=None, finish: pyqtSlot=None, workingdir: str=None) ->
p.finished.connect(finish)
return p

def checkDiskSpace(self, path: str):
def checkDiskSpace(self, path: str) -> None:
# noinspection PyCallByClass
if self.spaceWarningDelivered or not QFileInfo.exists(path):
return
Expand Down Expand Up @@ -478,17 +478,20 @@ def getBSF(self, source: str) -> tuple:
absf = '{} mp3decomp'.format(prefix)
return vbsf, absf

def probe(self, source: str) -> bool:
def probe(self, source: str, blackdetect: bool=False) -> Munch:
try:
args = '-v error -show_streams -show_format -of json "{}"'.format(source)
if blackdetect:
args = '-v error -f lavfi -i "movie={},blackdetect[out0]" -show_entries tags=lavfi.black_start,' \
'lavfi.black_end -of json'.format(source)
else:
args = '-v error -show_streams -show_format -of json "{}"'.format(source)
json_data = self.cmdExec(self.backends.ffprobe, args, output=True)
self.media = Munch.fromDict(json.loads(json_data))
return hasattr(self.media, 'streams') and len(self.media.streams)
return Munch.fromDict(loads(json_data))
except FileNotFoundError:
self.logger.exception('Probe media file not found: {}'.format(source), exc_info=True)
self.logger.exception('Media file for FFprobe not found: {}'.format(source), exc_info=True)
raise
except json.JSONDecodeError:
self.logger.exception('Error decoding ffprobe JSON output', exc_info=True)
except JSONDecodeError:
self.logger.exception('Error decoding FFprobe JSON output', exc_info=True)
raise

def getKeyframes(self, source: str, formatted_time: bool=False) -> list:
Expand Down Expand Up @@ -615,7 +618,9 @@ def cmdError(self, error: QProcess.ProcessError) -> None:

# noinspection PyUnresolvedReferences, PyProtectedMember
@staticmethod
def getAppPath() -> str:
def getAppPath(path: str=None) -> str:
if VideoService.frozen and getattr(sys, '_MEIPASS', False):
return sys._MEIPASS
return os.path.dirname(os.path.realpath(sys.argv[0]))
app_path = sys._MEIPASS
else:
app_path = os.path.dirname(os.path.realpath(sys.argv[0]))
return app_path if path is None else os.path.join(app_path, path)
6 changes: 3 additions & 3 deletions vidcutter/videocutter.py
Expand Up @@ -33,8 +33,8 @@
Qt, QTextStream, QTime, QTimer, QUrl)
from PyQt5.QtGui import QDesktopServices, QFont, QFontDatabase, QIcon, QKeyEvent, QPixmap
from PyQt5.QtWidgets import (QAction, qApp, QApplication, QFileDialog, QFrame, QGroupBox, QHBoxLayout, QLabel,
QListWidgetItem, QMenu, QMessageBox, QPushButton, QSizePolicy, QStyleFactory, QVBoxLayout,
QWidget)
QListWidgetItem, QMainWindow, QMenu, QMessageBox, QPushButton, QSizePolicy, QStyleFactory,
QVBoxLayout, QWidget)
import sip

# noinspection PyUnresolvedReferences
Expand Down Expand Up @@ -66,7 +66,7 @@ class VideoCutter(QWidget):
timeformat = 'hh:mm:ss.zzz'
runtimeformat = 'hh:mm:ss'

def __init__(self, parent: QWidget):
def __init__(self, parent: QMainWindow):
super(VideoCutter, self).__init__(parent)
self.setObjectName('videocutter')
self.logger = logging.getLogger(__name__)
Expand Down

0 comments on commit d8d1a72

Please sign in to comment.