video

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCRF = 25

Variables

This section is empty.

Functions

func DurationSeconds

func DurationSeconds(ctx context.Context, locator Locator, path string) (float64, error)

func EncodeFromPNGDir

func EncodeFromPNGDir(ctx context.Context, cfg EncodeConfig) error

func ExtractSegment

func ExtractSegment(ctx context.Context, locator Locator, src, dst string, fromSec, toSec float64, overwrite bool) error

ExtractSegment copies a time range from src into dst using ffmpeg.

func FileSizeMB

func FileSizeMB(path string) (float64, error)

func GetVideoInfo

func GetVideoInfo(ctx context.Context, locator Locator, videoPath string) (map[string]any, error)

GetVideoInfo mirrors lerobot.datasets.video_utils.get_video_info (v0.5.1).

func ImageDir

func ImageDir(videoKey string, episode int, root string) string

func ResolveEncoderThreads added in v1.1.0

func ResolveEncoderThreads() int

ResolveEncoderThreads reads LEROBOT_ENCODER_THREADS (0 when unset/invalid).

func SafeConcat

func SafeConcat(ctx context.Context, locator Locator, inputs []string, output string, overwrite bool) error

SafeConcat concatenates MP4 files with DTS monotonicity (tier-1 ffmpeg concat).

Types

type Config

type Config struct {
	FFmpegPath  string
	FFprobePath string
}

type EncodeConfig

type EncodeConfig struct {
	Locator    Locator
	VCodec     string
	CRF        int
	FPS        int
	Threads    int
	PNGPattern string
	OutputPath string
}

type H264RemuxEncoder added in v1.1.0

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

H264RemuxEncoder muxes Annex-B access units into MP4 via ffmpeg copy (no RGB round-trip).

func NewH264RemuxEncoder added in v1.1.0

func NewH264RemuxEncoder(ctx context.Context, locator Locator, fps int, outputPath string) (*H264RemuxEncoder, error)

NewH264RemuxEncoder starts ffmpeg in h264 copy mode.

func (*H264RemuxEncoder) Close added in v1.1.0

func (e *H264RemuxEncoder) Close() error

Close flushes stdin and waits for ffmpeg.

func (*H264RemuxEncoder) FrameCount added in v1.1.0

func (e *H264RemuxEncoder) FrameCount(ctx context.Context) (int, error)

FrameCount probes packet count via ffprobe when available.

func (*H264RemuxEncoder) OutputPath added in v1.1.0

func (e *H264RemuxEncoder) OutputPath() string

OutputPath returns the destination mp4 path.

func (*H264RemuxEncoder) WriteAccessUnits added in v1.1.0

func (e *H264RemuxEncoder) WriteAccessUnits(aus [][]byte) error

WriteAccessUnits writes ordered access units (nil entries are skipped).

type Locator

type Locator interface {
	FFmpegPath() (string, error)
	FFprobePath() (string, error)
}

func NewLocator

func NewLocator(cfg Config) Locator

type RawRGBEncoder added in v1.1.0

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

RawRGBEncoder streams raw RGB24 frames directly into an ffmpeg process for video dtype features. This avoids writing per-frame PNG files to tempfs/disk for the bulk of the episode, keeping memory bounded to in-flight decoded frames + small stats samples.

func NewRawRGBEncoder added in v1.1.0

func NewRawRGBEncoder(ctx context.Context, locator Locator, vcodec string, crf, fps, width, height int, outputPath string) (*RawRGBEncoder, error)

func (*RawRGBEncoder) Close added in v1.1.0

func (e *RawRGBEncoder) Close() error

func (*RawRGBEncoder) OutputPath added in v1.1.0

func (e *RawRGBEncoder) OutputPath() string

func (*RawRGBEncoder) WriteFrame added in v1.1.0

func (e *RawRGBEncoder) WriteFrame(frame VideoFrameRGB24) error

func (*RawRGBEncoder) WriteFrameBytes added in v1.1.0

func (e *RawRGBEncoder) WriteFrameBytes(rgb24 []byte) error

WriteFrameBytes keeps backward compatibility for callers still passing raw bytes.

type VideoFrameRGB24 added in v1.1.0

type VideoFrameRGB24 struct {
	Data   []byte
	Width  int
	Height int
}

VideoFrameRGB24 is the typed contract for streaming raw RGB24 into encoders.

func AsVideoFrameRGB24 added in v1.1.0

func AsVideoFrameRGB24(v any, width, height int) (VideoFrameRGB24, error)

AsVideoFrameRGB24 accepts typed frames or legacy []byte with explicit dimensions.

func ParseOptionalVideoFrameRGB24 added in v1.1.0

func ParseOptionalVideoFrameRGB24(v any, width, height int) (VideoFrameRGB24, bool, error)

ParseOptionalVideoFrameRGB24 parses a frame value; nil/absent input returns ok=false without error.

func (VideoFrameRGB24) ExpectedSize added in v1.1.0

func (f VideoFrameRGB24) ExpectedSize() int

func (VideoFrameRGB24) Validate added in v1.1.0

func (f VideoFrameRGB24) Validate() error

Jump to

Keyboard shortcuts

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