only process lines that start with "[Parsed_blackframe_"

There is no FFmpeg flag to hide metadata such as description
In our case, the metadata contained something that matched the regex.
This commit is contained in:
Kilian von Pflugk 2024-04-15 22:14:00 +02:00
parent 636630deb7
commit d288a2b5cf

View File

@ -261,24 +261,29 @@ public static class FFmpegWrapper
var raw = Encoding.UTF8.GetString(GetOutput(args, cacheKey, true)); var raw = Encoding.UTF8.GetString(GetOutput(args, cacheKey, true));
foreach (var line in raw.Split('\n')) foreach (var line in raw.Split('\n'))
{ {
var matches = BlackFrameRegex.Matches(line); // There is no FFmpeg flag to hide metadata such as description
if (matches.Count != 2) // In our case, the metadata contained something that matched the regex.
if (line.StartsWith("[Parsed_blackframe_", StringComparison.OrdinalIgnoreCase))
{ {
continue; var matches = BlackFrameRegex.Matches(line);
} if (matches.Count != 2)
{
continue;
}
var (strPercent, strTime) = ( var (strPercent, strTime) = (
matches[0].Value.Split(':')[1], matches[0].Value.Split(':')[1],
matches[1].Value.Split(':')[1] matches[1].Value.Split(':')[1]
); );
var bf = new BlackFrame( var bf = new BlackFrame(
Convert.ToInt32(strPercent, CultureInfo.InvariantCulture), Convert.ToInt32(strPercent, CultureInfo.InvariantCulture),
Convert.ToDouble(strTime, CultureInfo.InvariantCulture)); Convert.ToDouble(strTime, CultureInfo.InvariantCulture));
if (bf.Percentage > minimum) if (bf.Percentage > minimum)
{ {
blackFrames.Add(bf); blackFrames.Add(bf);
}
} }
} }