From 393e2c35e45cb971c4002cf20c5385bc87345554 Mon Sep 17 00:00:00 2001 From: ConfusedPolarBear <33811686+ConfusedPolarBear@users.noreply.github.com> Date: Mon, 13 Jun 2022 17:26:05 -0500 Subject: [PATCH] Improve ffmpeg feature detection --- .../Chromaprint.cs | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Chromaprint.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Chromaprint.cs index 1ad4594..46854a9 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Chromaprint.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Chromaprint.cs @@ -27,9 +27,33 @@ public static class Chromaprint { try { - var version = Encoding.UTF8.GetString(GetOutput("-version", 2000)); - Logger?.LogDebug("ffmpeg version: {Version}", version); - return version.Contains("--enable-chromaprint", StringComparison.OrdinalIgnoreCase); + // First, validate that the installed version of ffmpeg supports chromaprint at all. + var muxers = Encoding.UTF8.GetString(GetOutput("-muxers", 2000)); + Logger?.LogTrace("ffmpeg muxers: {Muxers}", muxers); + + if (!muxers.Contains("chromaprint", StringComparison.OrdinalIgnoreCase)) + { + Logger?.LogError("The installed version of ffmpeg does not support chromaprint"); + return false; + } + + // Second, validate that ffmpeg understands the "-fp_format raw" option. + var muxerHelp = Encoding.UTF8.GetString(GetOutput("-h muxer=chromaprint", 2000)); + Logger?.LogTrace("ffmpeg chromaprint help: {MuxerHelp}", muxerHelp); + + if (!muxerHelp.Contains("-fp_format", StringComparison.OrdinalIgnoreCase)) + { + Logger?.LogError("The installed version of ffmpeg does not support the -fp_format flag"); + return false; + } + else if (!muxerHelp.Contains("binary raw fingerprint", StringComparison.OrdinalIgnoreCase)) + { + Logger?.LogError("The installed version of ffmpeg does not support raw binary fingerprints"); + return false; + } + + Logger?.LogDebug("Installed version of ffmpeg meets fingerprinting requirements"); + return true; } catch {