fix: clear actionable error when ffmpeg/ffprobe is missing#182
Open
seonghobae wants to merge 1 commit into
Open
fix: clear actionable error when ffmpeg/ffprobe is missing#182seonghobae wants to merge 1 commit into
seonghobae wants to merge 1 commit into
Conversation
When ffmpeg or ffprobe is not installed or not on PATH, probe_media and
detect_silence_intervals let subprocess.run raise a bare FileNotFoundError
("No such file or directory: 'ffprobe'"), dumping a traceback that gives the
user no idea what went wrong. probe_media runs first in the pipeline, so this
raw error is what users actually hit — before the already-guarded _execute_plan.
Introduce a shared _run_media_tool() helper that maps a missing binary to a
MediaShrinkerError naming the tool and how to install it (brew/apt), and route
all three ffmpeg/ffprobe invocation sites through it. This also unifies and
improves _execute_plan's previously terse "ffmpeg not found: <path>" message.
Nonzero-exit / stderr handling stays at each call site; only the
tool-invocation FileNotFoundError path changes.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CJRVbDrp1vGYkJgNHMGPpG
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
When
ffmpeg/ffprobeis not installed or not on PATH,probe_mediaanddetect_silence_intervalsletsubprocess.runraise a bareFileNotFoundError:That is a raw traceback with zero guidance. Because
probe_mediaruns first in the conversion pipeline, this is the error users actually hit when ffmpeg isn't installed — long before reaching_execute_plan, which was already guarded. "ffmpeg not installed" is one of the most common user failures, so a clear message is genuine value.Fix
_run_media_tool()helper that runs an ffmpeg/ffprobe command and maps a missing binary to aMediaShrinkerErrorthat names the tool and how to install it (brew install ffmpeg/sudo apt install ffmpeg).probe_media,detect_silence_intervals,_execute_plan) through it. This also unifies and improves_execute_plan's previously terseffmpeg not found: <path>message.FileNotFoundErrorpath changes. No parsing, bitrate, or output-validation logic touched.Tests
TDD: added two tests asserting a clear
MediaShrinkerError(naming the binary + "Install ffmpeg") whensubprocess.runraisesFileNotFoundErrorfor missingffprobe(probe_media) and missingffmpeg(detect_silence_intervals). Both fail on the old raw-FileNotFoundErrorbehavior.Gates
coverage report --include=media_shrinker.py: 100%interrogate media_shrinker.py: 100%os.listxattrerrors remain)🤖 Generated with Claude Code