diff --git a/bin/pytop-0-0-1-x64.deb b/bin/pytop-0-0-1-x64.deb index e0e02c9..68dd6fb 100644 Binary files a/bin/pytop-0-0-1-x64.deb and b/bin/pytop-0-0-1-x64.deb differ diff --git a/src/Pytop/widgets/Grid.py b/src/Pytop/widgets/Grid.py index 6e81166..3154bd9 100644 --- a/src/Pytop/widgets/Grid.py +++ b/src/Pytop/widgets/Grid.py @@ -38,7 +38,6 @@ class Grid: self.vidsFilter = settings.returnVidsFilter() self.imagesFilter = settings.returnImagesFilter() self.iconFactory = Icon(settings) - self.helperThread = None # Helper thread object self.selectedFiles = [] self.currentPath = "" @@ -94,6 +93,7 @@ class Grid: image = self.iconFactory.createIcon(dirPath, file).get_pixbuf() glib.idle_add(self.addToGrid, (image, file,)) + @threaded def fillVideoIcons(self, dirPath, files, start): model = self.grid.get_model() @@ -104,11 +104,15 @@ class Grid: i = start for file in files: - image = self.iconFactory.createThumbnail(dirPath, file).get_pixbuf() - iter = model.get_iter_from_string(str(i)) - glib.idle_add(self.replaceInGrid, (iter, image,)) + self.updateGrid(model, dirPath, file, i) i += 1 + @threaded + def updateGrid(self, model, dirPath, file, i): + image = self.iconFactory.createThumbnail(dirPath, file).get_pixbuf() + iter = model.get_iter_from_string(str(i)) + glib.idle_add(self.replaceInGrid, (iter, image,)) + def addToGrid(self, dataSet): self.store.append([dataSet[0], dataSet[1]]) diff --git a/src/Pytop/widgets/Icon.py b/src/Pytop/widgets/Icon.py index e7a067a..e443d42 100644 --- a/src/Pytop/widgets/Icon.py +++ b/src/Pytop/widgets/Icon.py @@ -176,7 +176,33 @@ class Icon: def generateVideoThumbnail(self, fullPath, hashImgPth): proc = None try: - proc = subprocess.Popen(["ffmpeg", "-i", fullPath, "-vframes", "1", "-s", "320x180", "-q:v", "2", hashImgPth]) + # Stream duration + command = ["ffprobe", "-v", "error", "-select_streams", "v:0", "-show_entries", "stream=duration", "-of", "default=noprint_wrappers=1:nokey=1", fullPath] + data = subprocess.run(command, stdout=subprocess.PIPE) + duration = data.stdout.decode('utf-8') + + # Format (container) duration + if "N/A" in duration: + command = ["ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "default=noprint_wrappers=1:nokey=1", fullPath] + data = subprocess.run(command , stdout=subprocess.PIPE) + duration = data.stdout.decode('utf-8') + + # Stream duration type: image2 + if "N/A" in duration: + command = ["ffprobe", "-v", "error", "-select_streams", "v:0", "-f", "image2", "-show_entries", "stream=duration", "-of", "default=noprint_wrappers=1:nokey=1", fullPath] + data = subprocess.run(command, stdout=subprocess.PIPE) + duration = data.stdout.decode('utf-8') + + # Format (container) duration type: image2 + if "N/A" in duration: + command = ["ffprobe", "-v", "error", "-f", "image2", "-show_entries", "format=duration", "-of", "default=noprint_wrappers=1:nokey=1", fullPath] + data = subprocess.run(command , stdout=subprocess.PIPE) + duration = data.stdout.decode('utf-8') + + # Get frame roughly 35% through video + grabTime = str( int( float( duration.split(".")[0] ) * 0.35) ) + command = ["ffmpeg", "-ss", grabTime, "-an", "-i", fullPath, "-s", "320x180", "-vframes", "1", hashImgPth] + proc = subprocess.Popen(command) proc.wait() except Exception as e: print("Video thumbnail generation issue in thread:")