Update to PyQt6

This commit is contained in:
Jean-Claude 2023-08-17 09:54:54 +02:00
parent 8188964b7a
commit a7edc7bca4
Signed by: jeanclaude
GPG Key ID: 8A300F57CBB9F63E
1 changed files with 14 additions and 6 deletions

View File

@ -2,10 +2,9 @@
from typing import Any, BinaryIO
from PyQt5.QtGui import QPixmap, QImageReader
from PyQt5.QtCore import QProcess
from vimiv import api
from vimiv.qt.core import QProcess
from vimiv.qt.gui import QPixmap, QImageReader
from vimiv.utils import log
_logger = log.module_logger(__name__)
@ -47,10 +46,19 @@ def load_frame(path) -> QPixmap:
"""Extract the first frame from the video and initialize QPixmap"""
process = QProcess()
process.start(f"ffmpeg -loglevel quiet -i {path} -vframes 1 -f image2 pipe:1")
process.waitForFinished()
process.start(
"ffmpeg",
["-loglevel", "quiet", "-i", path, "-vframes", "1", "-f", "image2", "pipe:1"],
)
if not process.waitForFinished():
_logger.error(f"Process exited with code {process.exitCode()}")
raise OSError("Error waiting for process")
if process.exitStatus() != QProcess.NormalExit or process.exitCode() != 0:
if (
process.exitStatus() != QProcess.ExitStatus.NormalExit
or process.exitCode() != 0
):
_logger.error(f"Process exited with code {process.exitCode()}")
stderr = process.readAllStandardError()
raise ValueError(f"Error calling ffmpeg: '{stderr.data().decode()}'")