timecode

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package timecode formats and parses FFmpeg time durations.

Index

Constants

This section is empty.

Variables

View Source
var DefaultClock = FFmpegClock{}

DefaultClock is the FFmpeg duration clock.

View Source
var ErrInvalidTimecode = errors.New("invalid timecode")

ErrInvalidTimecode is returned when a timestamp string cannot be parsed.

Functions

This section is empty.

Types

type FFmpegClock

type FFmpegClock struct{}

FFmpegClock is the FFmpeg time-duration clock.

func (FFmpegClock) Format

func (FFmpegClock) Format(duration time.Duration) string

Format renders duration as HH:MM:SS.mmm.

func (FFmpegClock) Parse

func (clock FFmpegClock) Parse(value string) (time.Duration, error)

Parse accepts FFmpeg time durations: [-][HH:]MM:SS[.m...], [-]S+[.m...][s|ms|us].

type Timecode

type Timecode struct {
	// contains filtered or unexported fields
}

Timecode is a media timestamp.

func FromDuration

func FromDuration(d time.Duration) Timecode

FromDuration builds a timecode from a duration.

Parameters:

  • d: Backing duration. Signed values are kept.

Returns:

  • timecode: The timestamp.

func FromSeconds

func FromSeconds(seconds float64) Timecode

FromSeconds builds a timecode from a floating-point second count.

Parameters:

  • seconds: Timestamp in seconds. Negative, NaN, and Inf become zero.

Returns:

  • timecode: The timestamp, or a zero value when seconds is not finite.

func Parse

func Parse(value string) (Timecode, error)

Parse builds a timecode from an FFmpeg time-duration string.

Parameters:

  • value: An FFmpeg time-duration string.

Returns:

  • timecode: The parsed timestamp.
  • err: Non-nil when value is not a valid duration.

func (Timecode) Duration

func (t Timecode) Duration() time.Duration

Duration returns the backing duration.

Returns:

func (Timecode) HMS

func (t Timecode) HMS() string

HMS renders HH:MM:SS, rounding to the nearest second.

Returns:

  • clock: The timestamp as HH:MM:SS.

func (Timecode) Seconds

func (t Timecode) Seconds() float64

Seconds returns the timestamp in seconds.

Returns:

  • seconds: The timestamp as a floating-point second count.

func (Timecode) String

func (t Timecode) String() string

String renders HH:MM:SS.mmm.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL