Skip to content

Commit 2b4a1b6

Browse files
slhckclaude
andcommitted
feat: add --ffprobe-path option
Allow specifying a custom path to the ffprobe executable via CLI and API for environments where ffprobe is not in the default PATH. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 371e411 commit 2b4a1b6

3 files changed

Lines changed: 21 additions & 6 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ It will show a progress bar, and once the command is done, show the ffmpeg stder
123123
Full usage notes:
124124

125125
```
126-
usage: ffmpeg-progress-yield [-h] [-d DURATION] [-n] [-p] [-x] [-l LOG_FILE] ...
126+
usage: ffmpeg-progress-yield [-h] [-d DURATION] [-n] [-p] [-x] [-l LOG_FILE] [--ffprobe-path FFPROBE_PATH] ...
127127
128128
ffmpeg-progress-yield v0.12.0
129129
@@ -140,6 +140,8 @@ options:
140140
Exclude progress lines from ffmpeg log. (default: False)
141141
-l, --log-file LOG_FILE
142142
Send ffmpeg log output to specified file. (default: None)
143+
--ffprobe-path FFPROBE_PATH
144+
Path to ffprobe executable (for duration probing). (default: ffprobe)
143145
```
144146

145147
#### Duration override

src/ffmpeg_progress_yield/__main__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ def main() -> None:
3737
type=str,
3838
help="Send ffmpeg log output to specified file.",
3939
)
40+
parser.add_argument(
41+
"--ffprobe-path",
42+
type=str,
43+
default="ffprobe",
44+
help="Path to ffprobe executable (for duration probing)",
45+
)
4046
parser.add_argument(
4147
"ffmpeg_command",
4248
type=str,
@@ -49,6 +55,7 @@ def main() -> None:
4955
args.ffmpeg_command,
5056
dry_run=args.dry_run,
5157
exclude_progress=args.exclude_progress,
58+
ffprobe_path=args.ffprobe_path,
5259
) as ff:
5360
try:
5461
# Check if we should disable tqdm for testing, or in other cases

src/ffmpeg_progress_yield/ffmpeg_progress_yield.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,25 @@ class FfmpegProgress:
2525
PROGRESS_REGEX = re.compile(r"[a-z0-9_]+=.+")
2626

2727
def __init__(
28-
self, cmd: List[str], dry_run: bool = False, exclude_progress: bool = False
28+
self,
29+
cmd: List[str],
30+
dry_run: bool = False,
31+
exclude_progress: bool = False,
32+
ffprobe_path: str = "ffprobe",
2933
) -> None:
3034
"""Initialize the FfmpegProgress class.
3135
3236
Args:
3337
cmd (List[str]): A list of command line elements, e.g. ["ffmpeg", "-i", ...]
3438
dry_run (bool, optional): Only show what would be done. Defaults to False.
39+
exclude_progress (bool, optional): Exclude progress lines from output. Defaults to False.
40+
ffprobe_path (str, optional): Path to ffprobe executable. Defaults to "ffprobe".
3541
"""
3642
self.cmd = cmd
3743
self.stderr: Union[str, None] = None
3844
self.dry_run = dry_run
3945
self.exclude_progress = exclude_progress
46+
self.ffprobe_path = ffprobe_path
4047
self.process: Any = None
4148
self.stderr_callback: Union[Callable[[str], None], None] = None
4249
self.base_popen_kwargs = {
@@ -54,7 +61,7 @@ def __init__(
5461
self.current_input_idx: int = 0
5562
self.total_dur: Union[None, int] = None
5663
if FfmpegProgress._uses_error_loglevel(self.cmd):
57-
self.total_dur = FfmpegProgress._probe_duration(self.cmd)
64+
self.total_dur = self._probe_duration(self.cmd)
5865

5966
# Set up cleanup on garbage collection as a fallback
6067
self._cleanup_ref = weakref.finalize(self, self._cleanup_process, None)
@@ -173,8 +180,7 @@ def _process_output(
173180

174181
return progress
175182

176-
@staticmethod
177-
def _probe_duration(cmd: List[str]) -> Optional[int]:
183+
def _probe_duration(self, cmd: List[str]) -> Optional[int]:
178184
"""
179185
Get the duration via ffprobe from input media file
180186
in case ffmpeg was run with loglevel=error.
@@ -203,7 +209,7 @@ def _probe_duration(cmd: List[str]) -> Optional[int]:
203209
try:
204210
output = subprocess.check_output(
205211
[
206-
"ffprobe",
212+
self.ffprobe_path,
207213
"-loglevel",
208214
"error",
209215
"-hide_banner",

0 commit comments

Comments
 (0)