From 98a35ed00ddcc47dfeb1a1a26d4c7e3c4f864f6c Mon Sep 17 00:00:00 2001 From: kanehekili Date: Fri, 8 Apr 2022 21:15:48 +0200 Subject: [PATCH] Error Handling 2 --- src/FFMPEGTools.py | 7 ++++++- src/VideoCut.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/FFMPEGTools.py b/src/FFMPEGTools.py index cff6fbe..87ade8c 100644 --- a/src/FFMPEGTools.py +++ b/src/FFMPEGTools.py @@ -623,7 +623,7 @@ def __init__(self, video_file): def _readData(self): result = Popen(["ffprobe", "-show_format", "-show_streams", self.path, "-v", "quiet"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() if len(result[0]) == 0: - raise IOError('No such media file ' + self.path) + raise IOError('Not a media file ' + self.path) self.streams = [] datalines = [] self.video = [] @@ -653,6 +653,11 @@ def _readData(self): self.video.append(a) elif a.isSubTitle(): self.subtitle.append(a) + self.sanityCheck() + + def sanityCheck(self): + if self.getVideoStream() is None: + raise IOError("No video stream available") def getVideoStream(self): if len(self.video) == 0: diff --git a/src/VideoCut.py b/src/VideoCut.py index 3310f4b..da74959 100644 --- a/src/VideoCut.py +++ b/src/VideoCut.py @@ -1320,7 +1320,7 @@ def setFile(self, filePath): self.gui.updateWindowTitle(OSTools().getFileNameOnly(filePath)) self._initVideoViews() except Exception as ex: - Log.logException("Error 2") + Log.logException("Setting file") if not OSTools().fileExists(filePath): self.lastError = "File not found" else: