Convert frames (as integer) to correctly formatted video timecode


/ Published in: Other
Save to your folder(s)

Takes an integer value of frames (a) and converts it to a text formatted timecode "00:00:00:00" using the supplied framerate (b). Mainly for use in OpenOffice Calc.


Copy this code and paste it in your HTML
  1. Function FRAMESTOTC(a,b)
  2.  
  3. Dim HrsStr, MinsStr, SecsStr, FramesStr as String
  4. Dim HrsFinalStr, MinsFinalStr, SecsFinalStr, FramesFinalStr as String
  5. Dim MinsInt, SecsInt, FramesInt as Integer
  6. Dim HrsInt as Long
  7.  
  8. FramesInt = a mod b
  9. FramesStr = FramesInt
  10. If Len(FramesStr) = 1 Then
  11. FramesFinalStr = "0" & FramesStr
  12. Else
  13. FramesFinalStr = FramesStr
  14. End If
  15.  
  16.  
  17. SecsInt = ((a-FramesInt)/b) mod 60
  18. SecsStr = SecsInt
  19. If Len(SecsStr) = 1 Then
  20. SecsFinalStr = "0" & SecsStr
  21. Else
  22. SecsFinalStr = SecsStr
  23. End If
  24.  
  25. MinsInt = ((a-SecsInt*b-FramesInt)/(60*b)) mod 60
  26. MinsStr = MinsInt
  27. If Len(MinsStr) = 1 Then
  28. MinsFinalStr = "0" & MinsStr
  29. Else
  30. MinsFinalStr = MinsStr
  31. End If
  32.  
  33. HrsInt = ((a-MinsInt*b*60-SecsInt*b-FramesInt))/(60*60*b) mod 60
  34. HrsStr = HrsInt
  35. If Len(HrsStr) = 1 Then
  36. HrsFinalStr = "0" & HrsStr
  37. Else
  38. HrsFinalStr = HrsStr
  39. End If
  40.  
  41. FRAMESTOTC = HrsFinalStr & ":" & MinsFinalStr & ":" & SecsFinalStr & ":" & FramesFinalStr
  42.  
  43. End Function

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.