View Full Version : BCD time
Zeul
3rd October 2003, 13:04
hi guys. need a hand with converting a frame total into its equivalent BCD format , in VB NOT c, by passing the frame total and the FPS.
thanks
tateu
4th October 2003, 10:00
There are probably much better, faster, cleaner and simpler ways, but until someone else posts an answer, try this...
Function Frames_To_DVD_TimdeCode(ByVal TotalFrames As Integer, ByVal FPS As Double) As Long
Dim m_iFrame As Integer
Dim m_iSecond As Integer
Dim m_iMinute As Integer
Dim m_iHour As Integer
Dim DVD_TimeCode_FPS As Integer = CInt(FPS)
m_iFrame = TotalFrames Mod DVD_TimeCode_FPS
m_iSecond = Fix((TotalFrames Mod (60 * DVD_TimeCode_FPS)) / DVD_TimeCode_FPS)
m_iMinute = Fix((TotalFrames Mod (60 * 60 * DVD_TimeCode_FPS)) / (60 * DVD_TimeCode_FPS))
m_iHour = Fix(TotalFrames / (60 * 60 * DVD_TimeCode_FPS))
If FPS = 25 Then
Return (Fix(m_iHour / 10) << 28) Or ((m_iHour Mod 10) << 24) Or _
(Fix(m_iMinute / 10) << 20) Or ((m_iMinute Mod 10) << 16) Or _
(Fix(m_iSecond / 10) << 12) Or ((m_iSecond Mod 10) << 8) Or _
(&H40) Or _
((Fix(m_iFrame / 10) And &H3) << 4) Or (m_iFrame Mod 10)
ElseIf DVD_TimeCode_FPS = 30 Then
Return (Fix(m_iHour / 10) << 28) Or ((m_iHour Mod 10) << 24) Or _
(Fix(m_iMinute / 10) << 20) Or ((m_iMinute Mod 10) << 16) Or _
(Fix(m_iSecond / 10) << 12) Or ((m_iSecond Mod 10) << 8) Or _
(&HC0) Or _
((Fix(m_iFrame / 10) And &H3) << 4) Or (m_iFrame Mod 10)
Else
'Invalid fps value supplied for DVD BCD TimeCode
Return -1
End If
End Function
Zeul
4th October 2003, 11:13
thanks tateu, looks good will try that when home.
Zeul
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.