using System.Text.RegularExpressions; namespace ytLive.Services.Encoder; /// A decoded ffmpeg -stats progress line (pure data). public readonly record struct FfmpegProgress( long Frame, double Fps, double BitrateKbps, TimeSpan Duration, long SizeBytes); /// /// Pure parser for ffmpeg's periodic frame= fps= size= time= bitrate= stderr /// lines (the -stats/-stats_period output). Unit-tested in isolation /// so the encoder loop stays a thin wire. /// public static class FfmpegProgressParser { // frame= 123 fps= 59.9 q=28.0 size= 1024KiB time=00:00:02.04 bitrate= 4000.1kbits/s speed=1.00x private static readonly Regex Line = new( @"frame=\s*(?\d+)\s+fps=\s*(?[\d.]+).*?" + @"size=\s*(?\d+)KiB.*?" + @"time=(?