Skip to content

Commit ec7faa9

Browse files
CyanVoxelDandyDev01
authored andcommitted
fix: use absolute ffprobe path on macos (Fix TagStudioDev#511) (TagStudioDev#629)
* bump pyside version to 6.8.0.1 * fix: try for absolute ffprobe path on macos
1 parent 54e779a commit ec7faa9

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
@@ -811,24 +811,24 @@ def _image_vector_thumb(cls, filepath: Path, size: int) -> Image.Image:
811811
"""
812812
im: Image.Image = None
813813
# Create an image to draw the svg to and a painter to do the drawing
814-
image: QImage = QImage(size, size, QImage.Format.Format_ARGB32)
815-
image.fill("#1e1e1e")
814+
q_image: QImage = QImage(size, size, QImage.Format.Format_ARGB32)
815+
q_image.fill("#1e1e1e")
816816

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

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

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

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

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

0 commit comments

Comments
 (0)