4/11/2023 0 Comments Timecode calculator grun![]() Private static int FramesPerDay(short framesPerSecond)Īlthough I've been doing software development for a couple of years, I still wrestle over what I feel are simple decisions when it comes to things like class design, so I'm hoping to ask a few questions about my class and hope that someone can re-assure or advise otherwise. Return timecodeA.TotalSeconds() >= timecodeB.TotalSeconds() ![]() Public static bool operator >=(Timecode timecodeA, Timecode timecodeB) Return timecodeA.TotalSeconds() > timecodeB.TotalSeconds() Public static bool operator (Timecode timecodeA, Timecode timecodeB) Return new Timecode(timecodeA.totalFrames - frames, ameRate) Public static Timecode operator -(Timecode timecodeA, int frames) Int totalFramesB = timecodeB.totalFrames Int totalFramesA = timecodeA.totalFrames Throw new InvalidOperationException("Cannot subtract two timecodes with different framerates.") Public static Timecode operator -(Timecode timecodeA, Timecode timecodeB) / If the second timecode has fewer frames than the first, it is presumed to have rolled over the 24 hour mark and therefore be conceptually greater than the first. Return new Timecode(timecodeA.totalFrames + frames, ameRate) Public static Timecode operator +(Timecode timecodeA, int frames) / Adds a given number of frames to the timecode. Return new Timecode(timecodeA.totalFrames + timecodeB.totalFrames, ameRate) Throw new InvalidOperationException("Cannot add two timecodes with different framerates.") Public static Timecode operator +(Timecode timecodeA, Timecode timecodeB) Return new Timecode(hours, minutes, seconds, frames) Int frames = int.Parse(captureGroups.Value) ![]() Int seconds = int.Parse(captureGroups.Value) Int minutes = int.Parse(captureGroups.Value) Int hours = int.Parse(captureGroups.Value) GroupCollection captureGroups = TimecodeRegex.Match(timecodeStr).Groups Public static Timecode Parse(string timecodeStr, short framerate = 25) / Parses a timecode string of the format "hh:mm:ss:ff". / The total number of frames in one day, for this timecode's framerate. Private static string PadTimecodeUnit(int unit, int places = 2) / Pads a number for display in a timecode string. Return (float)this.totalFrames / (float)ameRate / The total number of seconds in this timecode. / The total number of frames for this timecode. Return (int)this.totalFrames / ameRate % 60 Return (int)this.totalFrames / ameRate / 60 % 60 Return (int)this.totalFrames / ameRate / 60 / 60 Public Timecode(int totalFrames, short frameRate = 25) Private static readonly Regex TimecodeRegex = new RegexOptions.Compiled | RegexOptions.ExplicitCapture) / Represents a timecode in hh:mm:ss:ff format. The "timecode" that I'm trying to represent is a timecode that is used in video editing quite often, and is seen displayed in the format "hh:mm:ss:ff", or 10:00:05:24, for example ("ff" = frames").
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |