Documentation
¶
Index ¶
- Variables
- func IsRepresentableFrames(frames uint64, num, den int32, opts ...IsRepresentableFramesOption) bool
- func IsSupportedFrameRate(num, den int32) bool
- type IsRepresentableFramesOption
- type IsRepresentableFramesOptionParam
- type ParseTimecodeOption
- type ParseTimecodeOptionParam
- type Timecode
- func (tc *Timecode) Add(other *Timecode) (*Timecode, error)
- func (tc *Timecode) AddFrames(frames uint64) (*Timecode, error)
- func (tc *Timecode) Duration() time.Duration
- func (tc *Timecode) FramerateDenominator() int32
- func (tc *Timecode) FramerateNumerator() int32
- func (tc *Timecode) Frames() uint64
- func (tc *Timecode) String() string
- func (tc *Timecode) Sub(other *Timecode) (*Timecode, error)
- func (tc *Timecode) SubFrames(frames uint64) (*Timecode, error)
- type TimecodeOption
- type TimecodeOptionParam
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNilTimecode = errors.New("nil timecode") // error for nil timecode ErrUnsupportedFrameRate = errors.New("unsupported frame rate") // error for unsupported frame rate ErrMismatchFrameRate = errors.New("mismatch frame rate") // error for mismatch frame rate ErrUnderflowFrames = errors.New("underflow frames") // error for underflow frames ErrInvalidTimecode = errors.New("invalid timecode") // error for invalid timecode ErrTooManyFrames = errors.New("too many frames") // error for too many frames )
Functions ¶
func IsRepresentableFrames ¶
func IsRepresentableFrames(frames uint64, num, den int32, opts ...IsRepresentableFramesOption) bool
IsRepresentableFrames returns whether frames is representable.
func IsSupportedFrameRate ¶
IsSupportedFrameRate returns whether frame rate is supported.
Types ¶
type IsRepresentableFramesOption ¶ added in v1.1.0
type IsRepresentableFramesOption func(*IsRepresentableFramesOptionParam)
IsRepresentableFramesOption represents IsRepresentableFrames option.
type IsRepresentableFramesOptionParam ¶ added in v1.1.0
type IsRepresentableFramesOptionParam struct {
ForceAsNDF bool
}
IsRepresentableFramesOptionParam represents IsRepresentableFrames option parameter.
type ParseTimecodeOption ¶ added in v1.1.0
type ParseTimecodeOption func(*ParseTimecodeOptionParam)
ParseTimecodeOption represents parse timecode option.
type ParseTimecodeOptionParam ¶ added in v1.1.0
TimecodeOptionParam represents timecode option parameter.
type Timecode ¶
type Timecode struct { HH uint64 MM uint64 SS uint64 FF uint64 // contains filtered or unexported fields }
Timecode represents timecode.
func NewTimecode ¶
func NewTimecode(frames uint64, num, den int32, opts ...TimecodeOption) (*Timecode, error)
NewTimecode returns new Timecode.
Example ¶
package main import ( "fmt" "github.com/abema/go-timecode/timecode" ) func main() { tc, err := timecode.NewTimecode(1800, 30000, 1001) if err != nil { panic(1) } fmt.Println(tc) }
Output: 00:01:00:02
func ParseTimecode ¶
func ParseTimecode(s string, num, den int32, opts ...ParseTimecodeOption) (*Timecode, error)
ParseTimecode returns new Timecode from formatted string.
Example ¶
package main import ( "fmt" "github.com/abema/go-timecode/timecode" ) func main() { tc, err := timecode.ParseTimecode("00:09:00:00", 30000, 1001) if err != nil { panic(1) } fmt.Println(tc) }
Output: 00:09:00:02
func Reset ¶
Reset returns new Timecode from Timecode and frames.
Example ¶
package main import ( "fmt" "github.com/abema/go-timecode/timecode" ) func main() { tc, err := timecode.NewTimecode(1798, 30000, 1001) if err != nil { panic(1) } tcc, _ := timecode.Reset(tc, 1800) fmt.Println(tcc) }
Output: 00:01:00:02
func (*Timecode) Add ¶
Add Timecode and Timecode and return new Timecode.
Example ¶
package main import ( "fmt" "github.com/abema/go-timecode/timecode" ) func main() { tc1, err := timecode.NewTimecode(1798, 30000, 1001) if err != nil { panic(1) } tc2, err := timecode.NewTimecode(2, 30000, 1001) if err != nil { panic(1) } tc3, _ := tc1.Add(tc2) fmt.Println(tc3) }
Output: 00:01:00:02
func (*Timecode) AddFrames ¶
Add Timecode and frames and return new Timecode.
Example ¶
package main import ( "fmt" "github.com/abema/go-timecode/timecode" ) func main() { tc1, err := timecode.NewTimecode(1798, 30000, 1001) if err != nil { panic(1) } tc2, _ := tc1.AddFrames(2) fmt.Println(tc2) }
Output: 00:01:00:02
func (*Timecode) FramerateDenominator ¶ added in v1.0.1
Framerate denominator.
func (*Timecode) FramerateNumerator ¶ added in v1.0.1
Framerate numerator.
func (*Timecode) String ¶
String returns Timecode formatted string. e.g. 01:23:45:28
Example ¶
package main import ( "fmt" "github.com/abema/go-timecode/timecode" ) func main() { tc, err := timecode.NewTimecode(3600, 60000, 1001) if err != nil { panic(1) } fmt.Println(tc.String()) }
Output: 00:01:00:04
func (*Timecode) Sub ¶
Sub Timecode and Timecode and return new Timecode.
Example ¶
package main import ( "fmt" "github.com/abema/go-timecode/timecode" ) func main() { tc1, err := timecode.NewTimecode(1800, 30000, 1001) if err != nil { panic(1) } tc2, err := timecode.NewTimecode(2, 30000, 1001) if err != nil { panic(1) } tc3, _ := tc1.Sub(tc2) fmt.Println(tc3) }
Output: 00:00:59:28
func (*Timecode) SubFrames ¶
Sub Timecode and frames and return new Timecode.
Example ¶
package main import ( "fmt" "github.com/abema/go-timecode/timecode" ) func main() { tc1, err := timecode.NewTimecode(1800, 30000, 1001) if err != nil { panic(1) } tc2, _ := tc1.SubFrames(2) fmt.Println(tc2) }
Output: 00:00:59:28
type TimecodeOption ¶
type TimecodeOption func(*TimecodeOptionParam)
TimecodeOption represents timecode option.
type TimecodeOptionParam ¶
TimecodeOptionParam represents timecode option parameter.