Revert FFmpeg path to full binary only; add separate FFprobe Binary Path field

This commit is contained in:
Forkless
2026-05-11 21:57:24 +02:00
parent 47e2407b38
commit 8f151daa25
27 changed files with 121 additions and 84 deletions
+5 -14
View File
@@ -436,24 +436,15 @@ class Cache_Manager {
$custom = $settings['piper_ffmpeg_binary'] ?? '';
if ( '' !== $custom ) {
// Support both full binary path AND directory-only path.
// `@is_dir` can return false under open_basedir, so we also
// try appending /ffmpeg if the raw path is not executable.
if ( ! @is_executable( $custom ) ) {
$candidate = rtrim( $custom, '/' ) . '/ffmpeg';
if ( @is_executable( $candidate ) ) {
$custom = $candidate;
$this->logger->info( 'FFmpeg path is a directory, resolved to: {path}', [ 'path' => $custom ] );
}
}
if ( @is_executable( $custom ) ) {
if ( @file_exists( $custom ) && @is_executable( $custom ) ) {
$cached = true;
$resolved_path = $custom;
$this->logger->info( 'Found ffmpeg at configured path: {path}', [ 'path' => $custom ] );
return $resolved_path;
}
$this->logger->warning( 'ffmpeg not found or not executable at configured path: {path}', [ 'path' => $original ] );
$this->logger->warning( 'Trying auto-detection.' );
$this->logger->warning(
'Configured ffmpeg binary not found or not executable: {path}. Trying auto-detection.',
[ 'path' => $custom ]
);
}
$candidates = apply_filters(
+7 -2
View File
@@ -184,8 +184,12 @@ class Settings {
],
], $this->page_slug_piper );
$this->add_field( 'piper_ffmpeg_binary', __( 'FFmpeg Binaries Path', 'piperless' ), 'text', 'piperless_piper_section', [
'description' => __( 'Absolute path to ffmpeg tools for MP3/Opus conversion. Auto-detected from common paths if left empty.', 'piperless' ),
$this->add_field( 'piper_ffmpeg_binary', __( 'FFmpeg Binary Path', 'piperless' ), 'text', 'piperless_piper_section', [
'description' => __( 'Absolute path to the ffmpeg binary for MP3/Opus conversion. Auto-detected from common paths if left empty.', 'piperless' ),
], $this->page_slug_piper );
$this->add_field( 'piper_ffprobe_binary', __( 'FFprobe Binary Path', 'piperless' ), 'text', 'piperless_piper_section', [
'description' => __( 'Absolute path to the ffprobe binary for audio duration detection. Auto-detected from the ffmpeg directory if left empty.', 'piperless' ),
], $this->page_slug_piper );
$this->add_field( 'piper_mp3_bitrate', __( 'MP3 Bitrate', 'piperless' ), 'select', 'piperless_piper_section', [
@@ -469,6 +473,7 @@ class Settings {
$clean['default_language'] = sanitize_text_field( $input['default_language'] ?? 'en_US' );
$clean['default_quality'] = sanitize_text_field( $input['default_quality'] ?? 'medium' );
$clean['piper_ffmpeg_binary'] = sanitize_text_field( $input['piper_ffmpeg_binary'] ?? '' );
$clean['piper_ffprobe_binary'] = sanitize_text_field( $input['piper_ffprobe_binary'] ?? '' );
$clean['piper_mp3_bitrate'] = sanitize_text_field( $input['piper_mp3_bitrate'] ?? '32k' );
$clean['piper_audio_format'] = in_array( $input['piper_audio_format'] ?? 'mp3', [ 'mp3', 'opus' ], true )
? $input['piper_audio_format'] : 'mp3';
+13 -4
View File
@@ -529,10 +529,19 @@ class Transcriber {
return $resolved;
}
$cached = true;
$cached = true;
$settings = get_option( 'piperless_settings', [] );
$custom = $settings['piper_ffprobe_binary'] ?? '';
// Use the same directory as ffmpeg — wherever it was resolved,
// ffprobe is likely right next to it.
// 1. Try the configured ffprobe path.
if ( '' !== $custom ) {
if ( @file_exists( $custom ) && @is_executable( $custom ) ) {
$resolved = $custom;
return $resolved;
}
}
// 2. Try the same directory as resolved ffmpeg.
$ffmpeg_path = $this->cache->find_ffmpeg();
if ( null !== $ffmpeg_path ) {
$candidate = dirname( $ffmpeg_path ) . '/ffprobe';
@@ -542,7 +551,7 @@ class Transcriber {
}
}
// Fallback: common paths extended via filter.
// 3. Fallback: common paths extended via filter.
$candidates = apply_filters(
'piperless_ffprobe_paths',
[ '/usr/bin/ffprobe', '/usr/local/bin/ffprobe', '/opt/bin/ffprobe' ]