fix: use absolute ffprobe path on macos (Fix #511) (#629)

* bump pyside version to 6.8.0.1

* fix: try for absolute ffprobe path on macos
This commit is contained in:
Travis Abendshien
2024-12-09 11:51:36 -08:00
committed by GitHub
parent aaea0b1475
commit a1daf5ab6a
3 changed files with 31 additions and 10 deletions

View File

@@ -8,9 +8,9 @@ pillow-heif==0.16.0
pillow-jxl-plugin==1.3.0
Pillow==10.3.0
pydub==0.25.1
PySide6_Addons==6.7.1
PySide6_Essentials==6.7.1
PySide6==6.7.1
PySide6_Addons==6.8.0.1
PySide6_Essentials==6.8.0.1
PySide6==6.8.0.1
rawpy==0.22.0
SQLAlchemy==2.0.34
structlog==24.4.0

View File

@@ -3,13 +3,34 @@
# Vendored from ffmpeg-python and ffmpeg-python PR#790 by amamic1803
import json
import platform
import shutil
import subprocess
import ffmpeg
import structlog
from src.qt.helpers.silent_popen import promptless_Popen
logger = structlog.get_logger(__name__)
def _probe(filename, cmd="ffprobe", timeout=None, **kwargs):
FFMPEG_MACOS_LOCATIONS: list[str] = ["", "/opt/homebrew/bin/", "/usr/local/bin/"]
def _get_ffprobe_location() -> str:
cmd: str = "ffprobe"
if platform.system() == "Darwin":
for loc in FFMPEG_MACOS_LOCATIONS:
if shutil.which(loc + cmd):
cmd = loc + cmd
break
logger.info(f"[FFPROBE] Using FFmpeg location: {cmd}")
return cmd
FFPROBE_CMD = _get_ffprobe_location()
def _probe(filename, cmd=FFPROBE_CMD, timeout=None, **kwargs):
"""Run ffprobe on the specified file and return a JSON representation of the output.
Raises:

View File

@@ -812,8 +812,8 @@ class ThumbRenderer(QObject):
"""
im: Image.Image = None
# Create an image to draw the svg to and a painter to do the drawing
image: QImage = QImage(size, size, QImage.Format.Format_ARGB32)
image.fill("#1e1e1e")
q_image: QImage = QImage(size, size, QImage.Format.Format_ARGB32)
q_image.fill("#1e1e1e")
# Create an svg renderer, then render to the painter
svg: QSvgRenderer = QSvgRenderer(str(filepath))
@@ -821,7 +821,7 @@ class ThumbRenderer(QObject):
if not svg.isValid():
raise UnidentifiedImageError
painter: QPainter = QPainter(image)
painter: QPainter = QPainter(q_image)
svg.setAspectRatioMode(Qt.AspectRatioMode.KeepAspectRatio)
svg.render(painter)
painter.end()
@@ -829,7 +829,7 @@ class ThumbRenderer(QObject):
# Write the image to a buffer as png
buffer: QBuffer = QBuffer()
buffer.open(QBuffer.OpenModeFlag.ReadWrite)
image.save(buffer, "PNG")
q_image.save(buffer, "PNG") # type: ignore[call-overload]
# Load the image from the buffer
im = Image.new("RGB", (size, size), color="#1e1e1e")
@@ -907,11 +907,11 @@ class ThumbRenderer(QObject):
| QPdfDocumentRenderOptions.RenderFlag.PathAliased
)
# Convert QImage to PIL Image
qimage: QImage = document.render(0, page_size.toSize(), render_options)
q_image: QImage = document.render(0, page_size.toSize(), render_options)
buffer: QBuffer = QBuffer()
buffer.open(QBuffer.OpenModeFlag.ReadWrite)
try:
qimage.save(buffer, "PNG")
q_image.save(buffer, "PNG") # type: ignore[call-overload]
im = Image.open(BytesIO(buffer.buffer().data()))
finally:
buffer.close()