public TimeCode(int hours, int minutes, int seconds, int frame = 0, FrameRate frameRate = FrameRate.Fps24) { var fps = frameRate.ToDouble(); var frameMs = MillisInt / fps * frame; var frameMsInt = (int)Math.Round(frameMs, MidpointRounding.AwayFromZero); TimeSpan = new TimeSpan(0, hours, minutes, seconds, frameMsInt); }
public static Timecode FromTimeSpan(TimeSpan ts, FrameRate frameRate, bool isDropFrame) { FrameRateSanityCheck(frameRate, isDropFrame); var tc = new Timecode(frameRate, isDropFrame) { TotalFrames = (int)Math.Round(ts.TotalSeconds * frameRate.ToDouble(), MidpointRounding.AwayFromZero) }; tc.UpdateByTotalFrames(); return(tc); }