Categorygithub.com/agorman/go-timecode/v2
modulepackage
2.0.3
Repository: https://github.com/agorman/go-timecode.git
Documentation: pkg.go.dev

# README

Build Status go report card GoDoc codecov

go-timecode

go-timecode simplifies the use of string based timecodes by providing conversions, frame based math, and support for SMTPE drop frame encoding. go-timecode offers a variety of industry standard formats out of the box but is designed to make it easy to work with any combination of formats you need.

Installation

go get github.com/agorman/go-timecode/v2

Documentation

https://godoc.org/github.com/agorman/go-timecode/v2

Basic usage

tc, err := timecode.Parse(timecode.R30, "01:30:12:15")
if err != nil {
    panic(err)
}

tc.String()   # "01:30:12:15"
tc.Frames()   # 162375
tc.Seconds()  # 5412.5
tc := timecode.FromFrames(timecode.R2997DF, 162213)

tc.String()   # "01:30:12:15"
tc.Frames()   # 162213
tc.Seconds()  # 5407.1
tc, err := timecode.FromSeconds(timecode.R2398, 5412.625)
if err != nil {
    panic(err)
}

tc.String()   # "01:30:12:15"
tc.Frames()   # 129903
tc.Seconds()  # 5412.625
rate, err := timecode.NewRate(30, false)
if err != nil {
    panic(err)
}
rate.FPS()         # 30.0
rate.DropFrame()   # false
rate, err := timecode.ParseRate("30000/1001", true)
if err != nil {
    panic(err)
}
rate.FPS()         # 29.97
rate.DropFrame()   # true

# Functions

FromFrames returns a Timecode based on the passed rate and frames.
FromSeconds returns a Timecode based on the passed rate and seconds.
NewRate returns a Rate baed on the given fps (frame rate) and dropFrame.
Parse takes rate and a timecode as a string in the form hh:mm:ss:ff.
ParseRate takes a frame rate string in a fractional form and returns a Rate object.

# Variables

R120 is Film 120 fps NDF.
R2398 is Film 23.99 fps NDF.
R24 is Film 23.99 fps NDF.
R240 is SMTPE 240 fps NDF.
R25 is EBU (European Broadcasting Union 25 fps NDF.
R2297 is SMPTE (Society of Motion Picture and Television Engineers) 29.97 fps NDF.
R2997DF is SMPTE (Society of Motion Picture and Television Engineers) 29.97 fps DF.
R30 is SMPTE (Society of Motion Picture and Television Engineers) 30 fps NDF.
R50 is EBU (European Broadcasting Union 50 fps NDF.
R5994 is SMPTE (Society of Motion Picture and Television Engineers) 59.94 fps NDF.
R5994DF is SMPTE (Society of Motion Picture and Television Engineers) 59.94 fps DF.
R60 is SMTPE (Society of Motion Picture and Television Engineers) 60 fps NDF.

# Structs

Rate describes a frame rate and drop frame encoding for a Timecode.
Timecode is used to simplify using string based timecodes by providing conversions, frame based math, and support for SMTPE drop frame encoding.