namespace AmiReel.Services;

/// <summary>
/// Recognizes the FFmpeg/FFprobe startup banner and stream-info boilerplate that both the
/// live log filter (<see cref="ProcessRunner"/>) and the error summarizer
/// (<see cref="UserFacingErrors"/>) want to hide — the version/library banner, input/output
/// stream dumps, and the final size/duration summary line are never useful to a user.
/// </summary>
public static class FfmpegOutputFilter
{
    private static readonly string[] BoilerplatePrefixes =
    [
        "ffmpeg version ",
        "built with ",
        "configuration:",
        "libavutil",
        "libavcodec",
        "libavformat",
        "libavdevice",
        "libavfilter",
        "libswscale",
        "libswresample",
        "Input #",
        "Output #",
        "Stream mapping:",
        "Stream #",
        "Metadata:",
        "Duration:",
        "Press [q] to stop",
        "video:",
        "audio:",
        "subtitle:",
        "other streams:",
        "global headers:",
        "muxing overhead:",
    ];

    public static bool IsBoilerplateLine(string line) =>
        BoilerplatePrefixes.Any(prefix => line.StartsWith(prefix, StringComparison.OrdinalIgnoreCase));
}
