guglcredits.blogg.se

Timecode calculator converter
Timecode calculator converter





timecode calculator converter

I have done this "rollover" in the constructor. I made the decision to rollover any timecode that goes beyond the 24 hour limit, because the timecodes I am used to using in media do the same. Do people agree with that assessment, or would you make it a method instead? Do my class properties (hours, minutes, seconds, frames) still satisfy the aforementioned statement? There is a small calculation in each, but it really is a very quick calculation. My basic understanding is that users of the class will view a property as little more than a field accessor, and therefore the implementation should be quick and clean and return as soon as possible. I often struggle to decide whether a class member should be a property or a method. The driving thought behind this decision was that it kept the class memory footprint much smaller, and I think calculations are much simpler this way. My fields are "totalFrames" and "frameRate", as opposed to a field for "hours", "minutes", "seconds", "frames", and "frameRate".

#Timecode calculator converter software#

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.")

timecode calculator converter

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").







Timecode calculator converter