Skip to content

Commit a1daf5a

Browse files
authored
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
1 parent aaea0b1 commit a1daf5a

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ pillow-heif==0.16.0
88
pillow-jxl-plugin==1.3.0
99
Pillow==10.3.0
1010
pydub==0.25.1
11-
PySide6_Addons==6.7.1
12-
PySide6_Essentials==6.7.1
13-
PySide6==6.7.1
11+
PySide6_Addons==6.8.0.1
12+
PySide6_Essentials==6.8.0.1
13+
PySide6==6.8.0.1
1414
rawpy==0.22.0
1515
SQLAlchemy==2.0.34
1616
structlog==24.4.0

tagstudio/src/qt/helpers/vendored/ffmpeg.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,34 @@
33
# Vendored from ffmpeg-python and ffmpeg-python PR#790 by amamic1803
44

55
import json
6+
import platform
7+
import shutil
68
import subprocess
79

810
import ffmpeg
11+
import structlog
912
from src.qt.helpers.silent_popen import promptless_Popen
1013

14+
logger = structlog.get_logger(__name__)
1115

12-
def _probe(filename, cmd="ffprobe", timeout=None, **kwargs):
16+
FFMPEG_MACOS_LOCATIONS: list[str] = ["", "/opt/homebrew/bin/", "/usr/local/bin/"]
17+
18+
19+
def _get_ffprobe_location() -> str:
20+
cmd: str = "ffprobe"
21+
if platform.system() == "Darwin":
22+
for loc in FFMPEG_MACOS_LOCATIONS:
23+
if shutil.which(loc + cmd):
24+
cmd = loc + cmd
25+
break
26+
logger.info(f"[FFPROBE] Using FFmpeg location: {cmd}")
27+
return cmd
28+
29+
30+
FFPROBE_CMD = _get_ffprobe_location()
31+
32+
33+
def _probe(filename, cmd=FFPROBE_CMD, timeout=None, **kwargs):
1334
"""Run ffprobe on the specified file and return a JSON representation of the output.
1435
1536
Raises:

tagstudio/src/qt/widgets/thumb_renderer.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -812,24 +812,24 @@ def _image_vector_thumb(cls, filepath: Path, size: int) -> Image.Image:
812812
"""
813813
im: Image.Image = None
814814
# Create an image to draw the svg to and a painter to do the drawing
815-
image: QImage = QImage(size, size, QImage.Format.Format_ARGB32)
816-
image.fill("#1e1e1e")
815+
q_image: QImage = QImage(size, size, QImage.Format.Format_ARGB32)
816+
q_image.fill("#1e1e1e")
817817

818818
# Create an svg renderer, then render to the painter
819819
svg: QSvgRenderer = QSvgRenderer(str(filepath))
820820

821821
if not svg.isValid():
822822
raise UnidentifiedImageError
823823

824-
painter: QPainter = QPainter(image)
824+
painter: QPainter = QPainter(q_image)
825825
svg.setAspectRatioMode(Qt.AspectRatioMode.KeepAspectRatio)
826826
svg.render(painter)
827827
painter.end()
828828

829829
# Write the image to a buffer as png
830830
buffer: QBuffer = QBuffer()
831831
buffer.open(QBuffer.OpenModeFlag.ReadWrite)
832-
image.save(buffer, "PNG")
832+
q_image.save(buffer, "PNG") # type: ignore[call-overload]
833833

834834
# Load the image from the buffer
835835
im = Image.new("RGB", (size, size), color="#1e1e1e")
@@ -907,11 +907,11 @@ def _pdf_thumb(cls, filepath: Path, size: int) -> Image.Image:
907907
| QPdfDocumentRenderOptions.RenderFlag.PathAliased
908908
)
909909
# Convert QImage to PIL Image
910-
qimage: QImage = document.render(0, page_size.toSize(), render_options)
910+
q_image: QImage = document.render(0, page_size.toSize(), render_options)
911911
buffer: QBuffer = QBuffer()
912912
buffer.open(QBuffer.OpenModeFlag.ReadWrite)
913913
try:
914-
qimage.save(buffer, "PNG")
914+
q_image.save(buffer, "PNG") # type: ignore[call-overload]
915915
im = Image.open(BytesIO(buffer.buffer().data()))
916916
finally:
917917
buffer.close()

0 commit comments

Comments
 (0)