ffglue

package module
v0.0.0-...-d11ca8c Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2025 License: AGPL-3.0 Imports: 12 Imported by: 0

README

go-ffglue

Go version of ffglue

What is ffglue?

ffglue is a collection of wrappers for ffmpeg and ffprobe to provide gracefull handling of execution and missing data under edge cases

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AttachmentCodec = &enum_codec_type{"A", "Attachment Codec"}
View Source
var AudioCodec = &enum_codec_type{"A", "Audio Codec"}
View Source
var CodecLUT = func(input []Codec) map[string]Codec {
	output := map[string]Codec{}
	for _, codec := range input {
		output[codec.Name] = codec
	}

	return output
}(Codecs)
View Source
var Codecs = func() []Codec {
	cmd := exec.Command(ffmpeg_filepath, "-codecs")
	var o bytes.Buffer
	cmd.Stdout = &o
	var e bytes.Buffer
	cmd.Stderr = &e

	run_res := blame.O0(cmd.Run())
	if run_res != nil {
		panic(run_res.WithAdditionalContext(e.String()))
	}
	o_s := o.String()
	header_and_body := strings.Split(o_s, "-------\n")
	body := header_and_body[1]
	lines := strings.Split(strings.TrimSpace(body), "\n")
	output := []Codec{}
	for _, line := range lines {
		l := nanolex.New(line)
		if pp, _ := l.Peek(-1); pp == ' ' {
			l.Read()
		}
		flags := l.ReadUntil(' ')
		l.ReadUntilNot(' ')

		name := l.ReadUntil(' ')
		l.ReadUntilNot(' ')

		description := l.ReadUntilEOF()

		codec := Codec{}
		codec.Flags = codec_flags_from(flags)
		codec.Name = name
		codec.Description = description
		output = append(output, codec)
	}

	return output
}()
View Source
var DataCodec = &enum_codec_type{"D", "Data Codec"}
View Source
var Presets = []string{"ultrafast", "superfast", "veryfast", "faster", "fast", "medium", "slow", "slower", "veryslow"}

TODO get this list dynamically

View Source
var SubtitleCodec = &enum_codec_type{"S", "Subtitle Codec"}
View Source
var VideoCodec = &enum_codec_type{"V", "Video Codec"}

Functions

func ReEncode

func ReEncode(tracker Int64Tracker, options ReEncodeOptions, output string) error

func ReEncodeArgv

func ReEncodeArgv(tracker Int64Tracker, throttle string, args ...string) error

func Thumb

func Thumb(input string, timestamp time.Duration, output string, dim Dimensions) error

func VideoDuration

func VideoDuration(to_probe string) (time.Duration, error)

Types

type Codec

type Codec struct {
	Flags       CodecFlags
	Name        string
	Description string
}

type CodecFlags

type CodecFlags struct {
	DecodingSupported bool
	EncodingSupported bool
	Type              *enum_codec_type
	IntraFrameOnly    bool
	Lossy             bool
	Losslss           bool
}

both Lossy and Losslss can be true simultaneously because of individual codec config options

func (CodecFlags) MarshalJSON

func (c CodecFlags) MarshalJSON() ([]byte, error)

func (CodecFlags) UnmarshalJSON

func (c CodecFlags) UnmarshalJSON(b []byte) error

type Dimensions

type Dimensions struct {
	W int
	H int
}

type ETA

type ETA struct {
	Average  ETAAverage
	Progress ETAProgress
}

type ETAAverage

type ETAAverage struct {
	Progress  time.Duration
	Cost      time.Duration
	Remaining time.Duration
	Speed     float64
	Samples   int
	N         int
}

type ETAProgress

type ETAProgress struct {
	Current time.Duration
	Total   time.Duration
}

type Int64Tracker

type Int64Tracker interface {
	ID() string

	ETA() ETA

	SetTotal(v int64)
	GetTotal() int64
	SetValue(v int64)
	GetValue() int64
	SetTitle(v string)
	GetTitle() string

	Start(*os.Process)
	Cancel() error
	Finish(error) error
}

type ReEncodeOptions

type ReEncodeOptions struct {
	Input    string
	Codec    string
	CRF      string
	Preset   string
	Extra    string
	Throttle string
}

Jump to

Keyboard shortcuts

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