Fix ab-av1 ffmpeg detection with temporary wrapper scripts (v2.34)

- ab-av1 requires ffmpeg/ffprobe to be in PATH (no CLI args/env vars for custom paths)
- Create temporary wrapper scripts that call tdarr-ffmpeg
- Add temp directory to PATH when executing ab-av1
- Clean up wrappers in finally block
- No permanent symlinks or system modifications needed
This commit is contained in:
Tdarr Plugin Developer
2025-12-15 23:15:50 -08:00
parent 2a3a619eb0
commit 5053386ca0
2 changed files with 28 additions and 5 deletions

View File

@@ -10,7 +10,7 @@ const details = () => ({
Features resolution-aware CRF, source-relative bitrate strategies, ab-av1 auto-CRF, and performance optimizations.
**Balanced defaults**: Preset 6, CRF 26, tune 0 (VQ), 10-bit, SCD 1, AQ 2, lookahead -1, TF on, keyint -2, fast-decode 0.
`,
Version: '2.33',
Version: '2.34',
Tags: 'video,av1,svt,quality,performance,speed-optimized,vbr,crf,vmaf',
Inputs: [
{
@@ -504,8 +504,21 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
// Returns { success: boolean, crf: number|null, vmaf: number|null, error: string|null }
const executeAbAv1CrfSearch = (abav1Path, inputFile, vmafTarget, sampleCount, preset) => {
const { execSync } = require('child_process');
const fs = require('fs');
const os = require('os');
const path = require('path');
// Create temp directory for ffmpeg/ffprobe wrappers
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ab-av1-'));
const ffmpegWrapper = path.join(tempDir, 'ffmpeg');
const ffprobeWrapper = path.join(tempDir, 'ffprobe');
try {
// Create wrapper scripts that call tdarr-ffmpeg
const wrapperScript = '#!/bin/sh\nexec tdarr-ffmpeg "$@"\n';
fs.writeFileSync(ffmpegWrapper, wrapperScript, { mode: 0o755 });
fs.writeFileSync(ffprobeWrapper, wrapperScript, { mode: 0o755 });
// Build ab-av1 command
// --min-vmaf is the target VMAF score to achieve
// --samples controls how many sample segments to test
@@ -522,7 +535,8 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
const command = `${abav1Path} ${args.join(' ')}`;
// Execute with timeout (5 minutes should be enough for sample encodes)
// Set FFMPEG and FFPROBE environment variables to point to tdarr-ffmpeg
// ab-av1 looks for 'ffmpeg' and 'ffprobe' in PATH
// Prepend temp directory to PATH so our wrappers are found first
const output = execSync(command, {
encoding: 'utf8',
timeout: 300000, // 5 minute timeout
@@ -530,8 +544,8 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
stdio: ['pipe', 'pipe', 'pipe'],
env: {
...process.env,
FFMPEG: 'tdarr-ffmpeg',
FFPROBE: 'tdarr-ffmpeg',
// Prepend temp dir so ab-av1 finds our ffmpeg/ffprobe wrappers
PATH: `${tempDir}:${process.env.PATH || ''}`,
}
});
@@ -574,6 +588,15 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
error: errorMsg,
output: error.stderr ? error.stderr.substring(0, 500) : ''
};
} finally {
// Clean up temp directory and wrapper scripts
try {
if (fs.existsSync(ffmpegWrapper)) fs.unlinkSync(ffmpegWrapper);
if (fs.existsSync(ffprobeWrapper)) fs.unlinkSync(ffprobeWrapper);
if (fs.existsSync(tempDir)) fs.rmdirSync(tempDir);
} catch (cleanupError) {
// Ignore cleanup errors
}
}
};

View File

@@ -1,7 +1,7 @@
# Tdarr Plugin Suite Documentation
> **Version**: 2025-12-16
> **Plugins**: misc_fixes v2.8 | stream_organizer v4.10 | audio_standardizer v1.15 | av1_converter v2.33
> **Plugins**: misc_fixes v2.8 | stream_organizer v4.10 | audio_standardizer v1.15 | av1_converter v2.34
---