SubtitleEdit/subtitleedit · error · FileNotFoundException

EBU header file not found: {ebuHeaderFile}

Error message

EBU header file not found: {ebuHeaderFile}

What it means

Thrown when the target format is EBU (binary .stl) and an EBU header file path was supplied via ebuHeaderFile, but that file does not exist (File.Exists returns false). The EBU format optionally uses a pre-built EbuGeneralSubtitleInformation header to control STL metadata; when specified it must be readable. The exception is a FileNotFoundException with the path as FileName.

Source

Thrown at src/seconv/Core/LibSEIntegration.cs:476

        {
            targetFormat.RemoveNativeFormatting(subtitle, sourceFormat);
        }

        var outputDir = Path.GetDirectoryName(filePath);
        if (!string.IsNullOrEmpty(outputDir) && !Directory.Exists(outputDir))
        {
            Directory.CreateDirectory(outputDir);
        }

        // Ebu (binary) — optional header file
        if (targetFormat is Ebu ebu)
        {
            Ebu.EbuGeneralSubtitleInformation? header = null;
            if (!string.IsNullOrEmpty(ebuHeaderFile))
            {
                if (!File.Exists(ebuHeaderFile))
                {
                    throw new FileNotFoundException($"EBU header file not found: {ebuHeaderFile}", ebuHeaderFile);
                }
                var headerBytes = File.ReadAllBytes(ebuHeaderFile);
                header = Ebu.ReadHeader(headerBytes);
            }
            ebu.Save(filePath, subtitle, true, header);
            return;
        }

        // Pac and PacUnicode (binary) — optional code page
        if (targetFormat is Pac pac)
        {
            if (pacCodePage.HasValue)
            {
                pac.CodePage = pacCodePage.Value;
            }
            pac.Save(filePath, subtitle);
            return;
        }

View on GitHub (pinned to 17a9f07487)

Solutions

  1. Verify the header file path with File.Exists before calling Save; if it is optional, omit it entirely when the file is absent.
  2. Resolve the path to an absolute path with Path.GetFullPath to avoid CWD ambiguity.
  3. If the header file was lost, regenerate it from the Subtitle Edit GUI EBU export dialog, or omit it to use LibSE's default header.

Example fix

// before
LibSEIntegration.SaveSubtitle(sub, outPath, "EBU", options, ebuHeaderFile: headerPath);

// after
if (!string.IsNullOrEmpty(headerPath) && !File.Exists(headerPath))
    throw new FileNotFoundException($"EBU header file not found: {headerPath}");
LibSEIntegration.SaveSubtitle(sub, outPath, "EBU", options, ebuHeaderFile: headerPath);
Defensive patterns

Strategy: validation

Validate before calling

if (!string.IsNullOrEmpty(ebuHeaderFile) && !File.Exists(ebuHeaderFile))
    throw new FileNotFoundException($"EBU header file not found: {ebuHeaderFile}", ebuHeaderFile);

Type guard

static bool IsEbuHeaderReadable(string path) => string.IsNullOrEmpty(path) || File.Exists(path);

Try / catch

try { LibSEIntegration.SaveSubtitle(sub, outPath, "EBU", options, ebuHeaderFile: headerPath); }
catch (FileNotFoundException ex) when (ex.Message.Contains("EBU header file not found"))
{ /* omit header or supply correct path */ }

Prevention

When it happens

Trigger: Calling the EBU save path with a non-null, non-empty ebuHeaderFile argument that does not resolve to an existing file. The file may have been moved, the path mistyped, or resolved relative to the wrong working directory.

Common situations: CLI --ebu-header pointing to a deleted or relocated file; a relative path in a script that breaks when CWD changes; sharing a config that references a machine-specific header file path.

Related errors


AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13). Data as JSON: /api/errors/748afb9b7a14a0c3. Report an issue: GitHub.