astiffmpeg

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: MIT Imports: 11 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Use your FFMpeg binary to manipulate your video files

Usage

WARNING: the code below doesn't handle errors for readibility purposes. However you SHOULD!

// Build astiffmpeg
var f = astiffmpeg.New(astiffmpeg.Configuration{BinaryPath: <your binary path>})

// Make sure stderr is parsed to retrieve ffmpeg progression
f.SetStdErrParser(astiffmpeg.DefaultStdErrParser(time.Second, func(r astiffmpeg.DefaultStdErrResults) {
    astilog.Debugf("time: %s", r.Time.String())
}))

Documentation

Index

Constants

View Source
const (
	// Show everything, including debugging information.
	LogLevelDebug = "debug"
	// Show all errors, including ones which can be recovered from.
	LogLevelError = "error"
	// Only show fatal errors. These are errors after which the process absolutely cannot continue.
	LogLevelFatal = "fatal"
	// Show informative messages during processing. This is in addition to warnings and errors. This is the default
	// value.
	LogLevelInfo = "info"
	// Only show fatal errors which could lead the process to crash, such as an assertion failure. This is not
	// currently used for anything.
	LogLevelPanic = "panic"
	// Show nothing at all; be silent.
	LogLevelQuiet = "quiet"
	// Same as info, except more verbose.
	LogLevelTrace = "trace"
	// Same as info, except more verbose.
	LogLevelVerbose = "verbose"
	// Show all warnings and errors. Any message related to possibly incorrect or unexpected events will be shown.
	LogLevelWarning = "warning"
)

Log levels

View Source
const (
	StreamSpecifierTypeAudio                = "a"
	StreamSpecifierTypeSubtitle             = "s"
	StreamSpecifierTypeVideo                = "v"
	StreamSpecifierTypeVideoAndNotThumbnail = "V"
)

Stream specifier types

View Source
const (
	DeinterlacingModeAdaptive = "adaptive"
	DeinterlacingModeBob      = "bob"
	DeinterlacingModeWeave    = "weave"
)

Deinterlacing modes

View Source
const (
	CoderAC      = "ac"
	CoderCABAC   = "cabac"
	CoderCAVLC   = "cavlc"
	CoderDefault = "default"
	CoderVLC     = "vlc"
)

Coders

View Source
const (
	PresetUltrafast = "ultrafast"
	PresetSuperfast = "superfast"
	PresetVeryfast  = "veryfast"
	PresetFaster    = "faster"
	PresetFast      = "fast"
	PresetMedium    = "medium"
	PresetSlow      = "slow"
	PresetSlower    = "slower"
	PresetVeryslow  = "veryslow"
)

Presets

View Source
const (
	ProfileBaseline = "baseline"
	ProfileHigh     = "high"
	ProfileHigh10   = "high10"
	ProfileHigh422  = "high422"
	ProfileHigh444  = "high444"
	ProfileMain     = "main"
)

Profiles

View Source
const (
	TuneAnimation   = "animation"
	TuneFastdecode  = "fastdecode"
	TuneFilm        = "film"
	TuneGrain       = "grain"
	TuneStillimage  = "stillimage"
	TuneZerolatency = "zerolatency"
)

Tunes

Variables

View Source
var (
	BinaryPath = flag.String("ffmpeg-binary-path", "", "the FFMpeg binary path")
)

Flags

Functions

This section is empty.

Types

type ComplexFilterOption

type ComplexFilterOption struct {
	Filters       []string
	InputStreams  []StreamSpecifier
	OutputStreams []StreamSpecifier
}

ComplexFilterOption represents complex filter options

type Configuration

type Configuration struct {
	BinaryPath string `toml:"binary_path"`
}

Configuration represents the ffmpeg configuration

func FlagConfig

func FlagConfig() Configuration

FlagConfig generates a Configuration based on flags

type DecodingOptions

type DecodingOptions struct {
	Codec                      *StreamOption
	DeinterlacingMode          string
	DropSecondField            *bool
	Duration                   time.Duration
	HardwareAcceleration       string
	HardwareAccelerationDevice *int
	Position                   time.Duration
}

DecodingOptions represents decoding options

type DefaultStdErrResults

type DefaultStdErrResults struct {
	Bitrate *float64 // bits/s
	FPS     *int
	Frame   *int
	Q       *float64
	Size    *int // bits
	Speed   *float64
	Time    *time.Duration
}

DefaultStdErrResults represents default stderr results

type EncodingOptions

type EncodingOptions struct {
	AudioSamplerate *int
	BFrames         *int
	Bitrate         []StreamOption
	BStrategy       *int
	BufSize         *Number
	Codec           []StreamOption
	Coder           string
	ComplexFilter   string
	ComplexFilters  []ComplexFilterOption
	ConstantQuality *float64
	CRF             *int
	Filters         []StreamOption
	Framerate       *float64
	Frames          []StreamOption
	GOP             *int
	KeyintMin       *int
	Level           *float64
	Maxrate         []StreamOption
	Minrate         []StreamOption
	Preset          string
	Profile         string
	Quality         []StreamOption
	RateControl     string
	SCThreshold     *int
	Tune            string
}

EncodingOptions represents encoding options

type FFMpeg

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

FFMpeg represents an entity capable of running an FFMpeg binary https://ffmpeg.org/ffmpeg.html

func New

func New(c Configuration) *FFMpeg

New creates a new FFMpeg

func (*FFMpeg) Exec

func (f *FFMpeg) Exec(ctx context.Context, g GlobalOptions, in []Input, out Output) (err error)

Exec executes the binary with the specified options ffmpeg [global_options] {[input_file_options] -i input_url} ... [output_file_options] output_url

func (*FFMpeg) SetStdErrParser

func (f *FFMpeg) SetStdErrParser(s StdErrParser)

SetStdErrParser sets the stderr parser

type FilterOptions

type FilterOptions struct {
	Format   *Format
	SAR      *Ratio
	Scale    *Scale
	ScaleNPP *Scale
	Select   string
}

FilterOptions represents filter options

type Format added in v0.3.0

type Format struct {
	PixelFormats []PixelFormat
}

Format represents a format filter

type GlobalOptions

type GlobalOptions struct {
	Log       *LogOptions
	NoStats   bool
	Overwrite *bool
	// Dump full command line and console output to a file named program-YYYYMMDD-HHMMSS.log in the current directory.
	// This file can be useful for bug reports. It also implies -loglevel verbose.
	Report bool
}

GlobalOptions represents global options

type Input

type Input struct {
	Options *InputOptions
	Path    string
}

Input represents an input

type InputOptions

type InputOptions struct {
	Decoding *DecodingOptions
}

InputOptions represents input options

type LogOptions

type LogOptions struct {
	Color    *bool
	Level    string
	Repeated bool
}

LogOptions represents log options

type MapOption

type MapOption struct {
	InputFileID int
	Stream      *StreamSpecifier
}

MapOption represents a map option

type MapOptions

type MapOptions []MapOption

MapOptions represents a set of map options

type Number

type Number struct {
	BinaryMultiple bool   // Result will be based on powers of 1024 instead of powers of 1000.
	ByteMultiple   bool   // Multiplies the value by 8.
	Prefix         string // K, M, G, ...
	Value          interface{}
}

Number represents a number which value can be shortened using string shortcuts

type Output

type Output struct {
	Options *OutputOptions
	Path    string
}

Output represents an output

type OutputOptions

type OutputOptions struct {
	Encoding *EncodingOptions
	Format   string
	Map      *MapOptions
}

OutputOptions represents output options

type PixelFormat added in v0.3.0

type PixelFormat string
const (
	PixelFormatRGBA PixelFormat = "rgba"
)

type Ratio

type Ratio struct {
	Antecedent, Consequent int
}

Ratio represents a ration

type Scale

type Scale struct {
	Height *int
	Width  *int
}

Scale represents a scale

type StdErrParser

type StdErrParser interface {
	Period() time.Duration
	Process(t time.Time, b *bytes.Buffer)
}

StdErrParser represents an object capable of parsing stderr

func DefaultStdErrParser

func DefaultStdErrParser(period time.Duration, fn func(r DefaultStdErrResults)) StdErrParser

DefaultStdErrParser creates the default stderr parser

type StreamOption

type StreamOption struct {
	Stream *StreamSpecifier
	Value  interface{}
}

SteamOption represents an option that can be specific to a stream

type StreamSpecifier

type StreamSpecifier struct {
	Index *int
	Name  string
	Type  string
}

StreamSpecifier represents a stream specifier

Jump to

Keyboard shortcuts

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