Timecode Calculator Brainache

Ali Edwards

Registered User.
Local time
Today, 11:05
Joined
Apr 19, 2001
Messages
68
Hi,

I've been trying to make what I thought would be a simple timecode calculator for calculating the duration of video/audio clips. Timecode format is HH:MM:SS:FF, where ff is 'frames'. I'm using 25 frames/second timecode, so 24 is the max value before 'FF' resets at 00 and 'SS' gains 1.

Assuming I can't use the normal date/time fields or functions (especially with my limited ability) I have created on a form 4 fields for timecode in, HH, MM, SS and FF and 4 for TC out.

Then I created 2 fields for the frame value of TC in and TC out:

TC in =(((([Tcin1]*60*60)+[Tcin2]*60)+[Tcin3])*25)+[Tcin4]
TC out =(((([Tcout1]*60*60)+[Tcout2]*60)+[Tcout3])*25)+[Tcout4]

and then another field to calculate the difference in frames, ie the total duration: TC out - TCin.

Now all I need to do is express the frame value in HH:MM:SS:FF but I can't fathom it!!

Help me please before my brain implodes!! :eek:
 
Ali,

Code:
NewVal  = tcOut - tcIn
Hours   = Nz(Int(NewVal/90000), 0)
NewVal  = NewVal - (Hours*90000)
Minutes = Nz(Int(NewVal/1500), 0)
NewVal  = NewVal - (Minutes*1500)
Seconds = Nz(Int(NewVal/25), 0)
NewVal  = NewVal - (Seconds*25)
Frames  = Nz(NewVal, 0)
TheAnswer = Format(Hours, "0#") & ":" & _
            Format(Minutes, "0#") & ":" & _
            Format(Seconds, "0#") & ":" & _
            Format(Frames, "0#")

Wayne
 
Wayne - you are a diamond!! It works!


Thank you thank you thank you. I've written pages and pages of code trying to do this and I never would have got there!

Cheers!
Ali :)
 
Video Timecode asp.net code required

Hi Ali,
is it possible for you to send me the video timecode. i am developing a video library system, it will be great helpful for me.
Thanks
 
Wayne did an **EXCELLENT** job of displaying the format.

If you don't want to code a VBA module, here is his code in a single line that can be inserted directly into a query, either on the design grid or in the SQL statement itself

Code:
Format((Nz(Int(CDbl((tcOut) - CDbl(tcIn)) / 90000), 0)), "0#") & ":" & 
Format((Nz(Int(((CDbl(tcOut) - CDbl(tcIn)) - ((Nz(Int(CDbl((tcOut) - CDbl(tcIn)) / 90000), 0)) * 90000)) / 1500), 0)), "0#") & ":" & 
Format((Nz(Int((((CDbl(tcOut) - CDbl(tcIn)) - ((Nz(Int(CDbl((tcOut) - CDbl(tcIn)) / 90000), 0)) * 90000)) - ((Nz(Int(((CDbl(tcOut) - CDbl(tcIn)) - ((Nz(Int(CDbl((tcOut) - CDbl(tcIn)) / 90000), 0)) * 90000)) / 1500), 0)) * 1500)) / 25), 0)), "0#") & ":" & 
Format((Nz(((((CDbl(tcOut) - CDbl(tcIn)) - ((Nz(Int(CDbl((tcOut) - CDbl(tcIn)) / 90000), 0)) * 90000)) - ((Nz(Int(((CDbl(tcOut) - CDbl(tcIn)) - ((Nz(Int(CDbl((tcOut) - CDbl(tcIn)) / 90000), 0)) * 90000)) / 1500), 0)) * 1500)) - ((Nz(Int((((CDbl(tcOut) - CDbl(tcIn)) - ((Nz(Int(CDbl((tcOut) - CDbl(tcIn)) / 90000), 0)) * 90000)) - ((Nz(Int(((CDbl(tcOut) - CDbl(tcIn)) - ((Nz(Int(CDbl((tcOut) - CDbl(tcIn)) / 90000), 0)) * 90000)) / 1500), 0)) * 1500)) / 25), 0)) * 25)), 0)), "0#")

Remember, if you paste the code in a grid field, change "Expr1" to a field name of your choice. If you pasted the code directly into the SQL window, add "AS MyFieldName" to the end of the code.
 
Help me in Tapecode Frame Calculation

Hi,
I am trying to solve this problem since 3 days but i am not able to solve it as i am new to ASP.Net. I will explain my scenario. i have a table called tblEvent where i stored all the program events. Each Event have MediaID,Title and Duration. this duration is actually time frame (00:06:30:23). I need to calculate all the time frame in the table and show the total time frame. Thats it. Please help me in this problem. if you can provide any sample application or script it would be great help.
I am making this application asp.net (VB.Net) and SQL Server 2000.

Thanks
 
Assuming that your time code is stored in tblTable.TimeString in this STRICT format:

HH:NN:SS:FF

Where:

HH = Hours digits
NN = Minutes digits
SS = Seconds digits
FF = Frames digits

EVERY element must be two characters long, so make sure you include leading zeroes for hours!

Queryfield:
Code:
Sum((CLng(Mid([TimeString],1,2))*0.0416666666666667)+(CLng(Mid([TimeString],4,2))*0.000694444444444444)+(CLng(Mid([TimeString],7,2))*0.0000115740740740741)+(CLng(Mid([TimeString],10,2))*0.000000482253086419753))

For your edification:


0.0416666666666667 = 1 hour = 1/24 of day
0.000694444444444444 = 1 minute = (1/60)/24 of day
0.0000115740740740741 = 1 second = (((1/24)/60)/60) of day
0.000000482253086419753 = 1 frame = ((((1/24)/60)/60)/24)

Basically, you are multiplying the elements of the time string by their constant given above to create a double number. Then you are adding up the numbers for your total sum.

Modify Wayne's formula to reconstitute the sum to the format, keeping in mind you will have to include a DAY value.

HTH
 

Users who are viewing this thread

Back
Top Bottom