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:
@@ -10,7 +10,7 @@ const details = () => ({
|
|||||||
Features resolution-aware CRF, source-relative bitrate strategies, ab-av1 auto-CRF, and performance optimizations.
|
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.
|
**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',
|
Tags: 'video,av1,svt,quality,performance,speed-optimized,vbr,crf,vmaf',
|
||||||
Inputs: [
|
Inputs: [
|
||||||
{
|
{
|
||||||
@@ -504,8 +504,21 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
|||||||
// Returns { success: boolean, crf: number|null, vmaf: number|null, error: string|null }
|
// Returns { success: boolean, crf: number|null, vmaf: number|null, error: string|null }
|
||||||
const executeAbAv1CrfSearch = (abav1Path, inputFile, vmafTarget, sampleCount, preset) => {
|
const executeAbAv1CrfSearch = (abav1Path, inputFile, vmafTarget, sampleCount, preset) => {
|
||||||
const { execSync } = require('child_process');
|
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 {
|
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
|
// Build ab-av1 command
|
||||||
// --min-vmaf is the target VMAF score to achieve
|
// --min-vmaf is the target VMAF score to achieve
|
||||||
// --samples controls how many sample segments to test
|
// --samples controls how many sample segments to test
|
||||||
@@ -522,7 +535,8 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
|||||||
const command = `${abav1Path} ${args.join(' ')}`;
|
const command = `${abav1Path} ${args.join(' ')}`;
|
||||||
|
|
||||||
// Execute with timeout (5 minutes should be enough for sample encodes)
|
// 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, {
|
const output = execSync(command, {
|
||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
timeout: 300000, // 5 minute timeout
|
timeout: 300000, // 5 minute timeout
|
||||||
@@ -530,8 +544,8 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
|||||||
stdio: ['pipe', 'pipe', 'pipe'],
|
stdio: ['pipe', 'pipe', 'pipe'],
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
FFMPEG: 'tdarr-ffmpeg',
|
// Prepend temp dir so ab-av1 finds our ffmpeg/ffprobe wrappers
|
||||||
FFPROBE: 'tdarr-ffmpeg',
|
PATH: `${tempDir}:${process.env.PATH || ''}`,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -574,6 +588,15 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
|||||||
error: errorMsg,
|
error: errorMsg,
|
||||||
output: error.stderr ? error.stderr.substring(0, 500) : ''
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Tdarr Plugin Suite Documentation
|
# Tdarr Plugin Suite Documentation
|
||||||
|
|
||||||
> **Version**: 2025-12-16
|
> **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
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user