-
-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Warn user if FFmpeg is not installed #441
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
39a9600
feat: Warn user if FFmpeg is not installed
seakrueger 0f54dcb
docs: Add FFmpeg installation guide
seakrueger afaae56
ruff formatting
seakrueger d2e0949
chore: Cleanup missing logic and warning message
seakrueger 1ad1313
chore: Remove custom icon
seakrueger 0f782f6
fix: Ignore dialog with X button
seakrueger 9f11182
fix: Move startup checks after CI
seakrueger a7d64ec
chore: Unreverse install check logic
seakrueger 01868d5
doc: Improve docs formatting
seakrueger 97c70b1
docs: Point help url to new docs sites
seakrueger 162b23d
Remove ffmpeg docs page
seakrueger c7d79b6
Use which from python stdlib
seakrueger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import logging | ||
import math | ||
from pathlib import Path | ||
import subprocess | ||
|
||
from PIL import Image, ImageQt | ||
from pydub.utils import which | ||
from PySide6.QtCore import Signal, Qt, QUrl | ||
from PySide6.QtGui import QPixmap, QDesktopServices | ||
from PySide6.QtWidgets import QMessageBox | ||
|
||
|
||
class FfmpegChecker(QMessageBox): | ||
"""A warning dialog for if FFmpeg is missing.""" | ||
|
||
HELP_URL = "https://docs.tagstud.io/help/ffmpeg/" | ||
|
||
def __init__(self): | ||
super().__init__() | ||
|
||
self.setWindowTitle("Warning: Missing dependency") | ||
self.setText("Warning: Could not find FFmpeg installation") | ||
self.setIcon(QMessageBox.Warning) | ||
# Blocks other application interactions until resolved | ||
self.setWindowModality(Qt.ApplicationModal) | ||
|
||
self.setStandardButtons( | ||
QMessageBox.Help | QMessageBox.Ignore | QMessageBox.Cancel | ||
) | ||
self.setDefaultButton(QMessageBox.Ignore) | ||
# Enables the cancel button but hides it to allow for click X to close dialog | ||
self.button(QMessageBox.Cancel).hide() | ||
|
||
self.ffmpeg = False | ||
self.ffprobe = False | ||
|
||
def installed(self): | ||
"""Checks if both FFmpeg and FFprobe are installed and in the PATH.""" | ||
# Same checker that ffmpeg-python uses | ||
if which("ffmpeg"): | ||
self.ffmpeg = True | ||
if which("ffprobe"): | ||
self.ffprobe = True | ||
|
||
logging.info( | ||
f"[FFmpegChecker] FFmpeg found: {self.ffmpeg}, FFprobe found: {self.ffprobe}" | ||
) | ||
return self.ffmpeg and self.ffprobe | ||
|
||
def show_warning(self): | ||
"""Displays the warning to the user and awaits respone.""" | ||
missing = "FFmpeg" | ||
# If ffmpeg is installed but not ffprobe | ||
if not self.ffprobe and self.ffmpeg: | ||
missing = "FFprobe" | ||
|
||
self.setText(f"Warning: Could not find {missing} installation") | ||
self.setInformativeText( | ||
f"{missing} is required for multimedia thumbnails and playback" | ||
) | ||
# Shows the dialog | ||
selection = self.exec() | ||
|
||
# Selection will either be QMessageBox.Help or (QMessageBox.Ignore | QMessageBox.Cancel) which can be ignored | ||
if selection == QMessageBox.Help: | ||
QDesktopServices.openUrl(QUrl(self.HELP_URL)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont like this implementation of which, it could just have been a method in your class, but since it ships with ffmpegs install it is fine to use. But, it uses
os.name
for platform checking, and I have seen many discussion about this usage and how it is better to useplatform.system()
to get the current platform name.It also uses os.path instead of
pathlib
I would like @CyanVoxel to comment on this. I can write the method if that is wanted as a new PR after this is merged. there is currently nothing wrong about this usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could
shutil.which()
be used here instead?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not know the Python stdlib had a built in which command, using that instead.