moviego

package module
v0.0.0-...-25e053e Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: GPL-3.0 Imports: 17 Imported by: 0

README

MovieGo

Go library for video editing using FFmpeg. Build video pipelines programmatically.

Requirements

  • FFmpeg installed and available in PATH

Installation

go get github.com/YounesseAmhend/MovieGo

Quick Start

package main

import (
    "github.com/YounesseAmhend/MovieGo"
)

func main() {
    v, err := moviego.NewVideoFile("input.mp4")
    if err != nil {
        panic(err)
    }

    cut, _ := v.Cut(0, 10)
    cut, _ = cut.Scale(moviego.ScaleParams{Width: 1280, Height: 720})
    cut, _ = cut.Eq(moviego.EqParams{Gamma: moviego.F(1.2)})
    cut, _ = cut.FadeIn(1.0)

    cut.WriteVideo(moviego.VideoParameters{
        OutputPath: "output.mp4",
        Codec:      moviego.CodecH264,
        Fps:        30,
    })
}

Features

  • Video I/O – Load, cut, trim, concatenate
  • Filters – Brightness, contrast, saturation, gamma, blur, sharpen, hue, vignette
  • Effects – Fade in/out, grayscale, sepia, negate
  • Transitions – Wipe, dissolve, fade between clips
  • Compositing – Overlay clips, mix audio
  • Animations – Scale, rotate, blur, color over time
  • Text – Burn-in subtitles
  • Speed – Change playback speed with optional pitch correction

Optional Parameters

For filters like Eq and Hue, use moviego.F(value) for optional params. Nil means “use FFmpeg default”:

// Only gamma, rest use defaults
video.Eq(moviego.EqParams{Gamma: moviego.F(1.2)})

// Full control
video.Eq(moviego.EqParams{
    Brightness: moviego.F(0.1),
    Contrast:   moviego.F(1.2),
    Saturation: moviego.F(1.5),
    Gamma:      moviego.F(1.0),
})

License

See LICENSE file.

Documentation

Index

Constants

View Source
const (
	// Software encoder presets (libx264, libx265, etc.)
	UltraFast preset = "ultrafast"
	SuperFast preset = "superfast"
	VeryFast  preset = "veryfast"
	Fast      preset = "fast"
	Medium    preset = "medium"
	Slow      preset = "slow"
	VerySlow  preset = "veryslow"
	Placebo   preset = "placebo"
)

Variables

This section is empty.

Functions

func F

func F(v float64) *float64

F returns a pointer to v for use in optional *float64 struct fields.

Types

type AnimatedColor

type AnimatedColor struct {
	Brightness *Animation // -1 to 1
	Contrast   *Animation // -1000 to 1000
	Saturation *Animation // 0 to 3
	Hue        *Animation // degrees
}

AnimatedColor animates color properties over time. Nil fields are not animated.

type AnimatedPosition

type AnimatedPosition struct {
	Start     Position
	End       Position
	StartTime float64
	EndTime   float64
	Curve     Curve
}

AnimatedPosition interpolates a position from Start to End.

func (AnimatedPosition) ToExprXForTest

func (ap AnimatedPosition) ToExprXForTest(timeVar string) string

ToExprXForTest returns the X expression for testing.

func (AnimatedPosition) ToExprYForTest

func (ap AnimatedPosition) ToExprYForTest(timeVar string) string

ToExprYForTest returns the Y expression for testing.

type Animation

type Animation struct {
	Start     float64
	End       float64
	StartTime float64
	EndTime   float64
	Curve     Curve
}

Animation interpolates a single float from Start to End over a time range.

func (Animation) ToExprForTest

func (a Animation) ToExprForTest(timeVar string) string

ToExprForTest returns the FFmpeg expression for testing.

type Audio

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

func AudioFile

func AudioFile(filename string) (*Audio, error)

AudioFile probes an audio file using ffprobe and returns an Audio with its metadata populated (codec, sample rate, channels, bit rate, duration).

func Composite

func Composite(audios []Audio) (*Audio, error)

Composite mixes multiple audio tracks together. Audio from all sources is mixed using amix.

func (*Audio) BassBoost

func (a *Audio) BassBoost(gain float64) (*Audio, error)

BassBoost boosts the bass frequencies.

func (*Audio) BitRate

func (a *Audio) BitRate(bitRate uint64) *Audio

func (*Audio) Bps

func (a *Audio) Bps(bps uint) *Audio

func (*Audio) Channels

func (a *Audio) Channels(channels uint8) *Audio

func (*Audio) Codec

func (a *Audio) Codec(codec string) *Audio

func (*Audio) Duration

func (a *Audio) Duration(duration float64) *Audio

func (*Audio) Echo

func (a *Audio) Echo(delay, decay float64) (*Audio, error)

Echo applies an echo effect. delay: delay in milliseconds, decay: decay amount (0-1).

func (*Audio) FadeIn

func (a *Audio) FadeIn(duration float64) (*Audio, error)

FadeIn applies a fade-in effect at the start.

func (*Audio) FadeOut

func (a *Audio) FadeOut(duration float64) (*Audio, error)

FadeOut applies a fade-out effect ending at the audio's duration.

func (*Audio) GetBitRate

func (a *Audio) GetBitRate() uint64

func (*Audio) GetBps

func (a *Audio) GetBps() uint

func (*Audio) GetChannels

func (a *Audio) GetChannels() uint8

func (*Audio) GetCodec

func (a *Audio) GetCodec() string

func (*Audio) GetDuration

func (a *Audio) GetDuration() float64

func (*Audio) GetFilenames

func (a *Audio) GetFilenames() []string

func (*Audio) GetSampleRate

func (a *Audio) GetSampleRate() uint64

func (*Audio) HighPass

func (a *Audio) HighPass(freq float64) (*Audio, error)

HighPass applies a high-pass filter with the given frequency.

func (*Audio) LowPass

func (a *Audio) LowPass(freq float64) (*Audio, error)

LowPass applies a low-pass filter with the given frequency.

func (*Audio) MuteRanges

func (a *Audio) MuteRanges(ranges []TimeRange) (*Audio, error)

MuteRanges mutes audio only during the specified time ranges. Uses FFmpeg's volume filter with enable='between(t,s1,e1)+between(t,s2,e2)+...'. If ranges is empty, returns the audio unchanged.

func (*Audio) Normalize

func (a *Audio) Normalize() (*Audio, error)

Normalize normalizes the audio levels.

func (*Audio) SampleRate

func (a *Audio) SampleRate(sampleRate uint64) *Audio

func (*Audio) SetFilename

func (a *Audio) SetFilename(filenames []string) *Audio

func (*Audio) Tempo

func (a *Audio) Tempo(tempo float64) (*Audio, error)

Tempo changes the audio tempo without changing pitch. Supported range: 0.5 to 100.0.

func (*Audio) TrebleBoost

func (a *Audio) TrebleBoost(gain float64) (*Audio, error)

TrebleBoost boosts the treble frequencies.

func (*Audio) Volume

func (a *Audio) Volume(volume float64) (*Audio, error)

Volume adjusts the audio volume (0.0 = silent, 1.0 = normal, >1.0 = louder).

func (*Audio) Write

func (a *Audio) Write(parms AudioParameters) error

Write processes the audio with applied filters and writes to output file

type AudioCodec

type AudioCodec string
const (
	AudioCodecAAC    AudioCodec = "aac"
	AudioCodecMP3    AudioCodec = "libmp3lame"
	AudioCodecFLAC   AudioCodec = "flac"
	AudioCodecOpus   AudioCodec = "libopus"
	AudioCodecVorbis AudioCodec = "libvorbis"
	AudioCodecPCM    AudioCodec = "pcm_s16le"
)

type AudioParameters

type AudioParameters struct {
	OutputPath string
	Threads    uint16
	Codec      AudioCodec
	SampleRate uint64
	Channels   uint8
	Bitrate    uint64
	// SilentProgress disables the default colored progress bar.
	SilentProgress bool
	// OnProgress, when set, replaces the default colored progress bar.
	OnProgress func(Progress)
}

AudioParameters holds configuration for audio processing.

type Background

type Background struct {
	Enabled bool   // show background box
	Color   string // box fill color, e.g. "black@0.5" (default: "white")
	Padding string // padding inside box: "10" or per-side "10|20|30|40"
	Width   int    // explicit box width (0 = auto-fit text)
	Height  int    // explicit box height (0 = auto-fit text)
}

Background controls the box drawn behind text.

type Clip

type Clip interface {
	GetWidth() uint64
	GetHeight() uint64
	GetDuration() float64
	GetPosition() Position
}

Clip is the shared interface for visual clip types (Video and ImageClip). Audio intentionally does not implement this interface since it has no visual dimensions.

type Codec

type Codec string
const (
	// H.264/AVC codecs
	CodecH264      Codec = "h264"
	CodecLibx264   Codec = "libx264"
	CodecH264Auto  Codec = "h264_auto"
	CodecH264Nvenc Codec = "h264_nvenc"
	CodecH264Qsv   Codec = "h264_qsv"
	CodecH264Amf   Codec = "h264_amf"
	CodecH264Vt    Codec = "h264_videotoolbox"

	// H.265/HEVC codecs
	CodecH265      Codec = "h265"
	CodecHevc      Codec = "hevc"
	CodecLibx265   Codec = "libx265"
	CodecHevcNvenc Codec = "hevc_nvenc"
	CodecHevcQsv   Codec = "hevc_qsv"
	CodecHevcAmf   Codec = "hevc_amf"
	CodecHevcVt    Codec = "hevc_videotoolbox"

	// VP8/VP9 codecs
	CodecVP8       Codec = "vp8"
	CodecVP9       Codec = "vp9"
	CodecLibvpx    Codec = "libvpx"
	CodecLibvpxVP9 Codec = "libvpx-vp9"

	// AV1 codecs
	CodecAV1       Codec = "av1"
	CodecLibaomAV1 Codec = "libaom-av1"
	CodecLibsvtav1 Codec = "libsvtav1"
	CodecAV1Nvenc  Codec = "av1_nvenc"
	CodecAV1Qsv    Codec = "av1_qsv"

	// MPEG codecs
	CodecMpeg2video Codec = "mpeg2video"
	CodecMpeg4      Codec = "mpeg4"
	CodecMpeg1video Codec = "mpeg1video"

	// Other codecs
	CodecTheora   Codec = "theora"
	CodecWmv1     Codec = "wmv1"
	CodecWmv2     Codec = "wmv2"
	CodecWmv3     Codec = "wmv3"
	CodecVc1      Codec = "vc1"
	CodecProres   Codec = "prores"
	CodecProresKS Codec = "prores_ks"
	CodecDNxHD    Codec = "dnxhd"
	CodecDNxHR    Codec = "dnxhr"
	CodecHuffYUV  Codec = "huffyuv"
	CodecFFV1     Codec = "ffv1"
	CodecUtvideo  Codec = "utvideo"
	CodecMjpeg    Codec = "mjpeg"
	CodecLibxvid  Codec = "libxvid"
)

type CropParams

type CropParams struct {
	X      int
	Y      int
	Width  int
	Height int
}

CropParams holds parameters for the crop filter.

type Curve

type Curve int

Curve defines the interpolation curve between start and end values.

const (
	Linear Curve = iota

	// Quadratic
	EaseIn
	EaseOut
	EaseInOut

	// Cubic
	CubicIn
	CubicOut
	CubicInOut

	// Quartic
	QuartIn
	QuartOut
	QuartInOut

	// Quintic
	QuintIn
	QuintOut
	QuintInOut

	// Sine
	SineIn
	SineOut
	SineInOut

	// Exponential
	ExpoIn
	ExpoOut
	ExpoInOut

	// Circular
	CircIn
	CircOut
	CircInOut

	// Back (overshoots then settles)
	BackIn
	BackOut
	BackInOut

	// Elastic (spring-like oscillation)
	ElasticIn
	ElasticOut
	ElasticInOut

	// Bounce (ball drop)
	BounceIn
	BounceOut
	BounceInOut

	// Spring (damped spring)
	Spring

	// Steps (discrete jumps)
	Steps
)

type EqParams

type EqParams struct {
	Brightness *float64 // -1 to 1, default 0
	Contrast   *float64 // -1000 to 1000, default 1
	Saturation *float64 // 0 to 3, default 1
	Gamma      *float64 // 0.1 to 10, default 1
}

EqParams holds parameters for the eq (equalizer) filter: brightness, contrast, saturation, gamma. Nil fields use ffmpeg defaults (brightness=0, contrast=1, saturation=1, gamma=1).

type FileCopy

type FileCopy struct {
	Filename string
	Label    string
}

type FilterComplex

type FilterComplex struct {
	FilterElement string
	FileCopy      FileCopy
	Label         string
	Order         uint64
}

type HueParams

type HueParams struct {
	Degrees    *float64 // hue angle in degrees, default 0
	Saturation *float64 // -10 to 10, default 1
}

HueParams holds parameters for the hue filter. Nil fields use ffmpeg defaults (degrees=0, saturation=1).

type ImageClip

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

ImageClip represents a still image used as a clip in compositions/timelines. It carries only image-relevant fields — no audio, codec, fps, or video filter chains.

func NewImageClip

func NewImageClip(filename string, width, height uint64, duration float64) *ImageClip

NewImageClip creates a new ImageClip with the given filename, dimensions, and duration.

func (*ImageClip) Duration

func (ic *ImageClip) Duration(d float64) *ImageClip

Duration sets how long the image should be displayed.

func (*ImageClip) GetDuration

func (ic *ImageClip) GetDuration() float64

GetDuration returns how long the image should be displayed.

func (*ImageClip) GetFilename

func (ic *ImageClip) GetFilename() string

GetFilename returns the image filename.

func (*ImageClip) GetHeight

func (ic *ImageClip) GetHeight() uint64

GetHeight returns the image height.

func (*ImageClip) GetPosition

func (ic *ImageClip) GetPosition() Position

GetPosition returns the overlay position. Returns center position if none was explicitly set.

func (*ImageClip) GetWidth

func (ic *ImageClip) GetWidth() uint64

GetWidth returns the image width.

func (*ImageClip) SetAnimatedOpacity

func (ic *ImageClip) SetAnimatedOpacity(a Animation) *ImageClip

SetAnimatedOpacity sets the overlay opacity animation for CompositeClip.

func (*ImageClip) SetAnimatedPosition

func (ic *ImageClip) SetAnimatedPosition(ap AnimatedPosition) *ImageClip

SetAnimatedPosition sets the overlay position animation for CompositeClip.

func (*ImageClip) SetPosition

func (ic *ImageClip) SetPosition(position Position) *ImageClip

SetPosition sets the overlay position used by CompositeClip.

type Layout

type Layout struct {
	LineSpacing int    // extra spacing between lines in pixels
	TabSize     int    // tab character width in spaces (default: 4)
	Align       string // multi-line alignment: "L"/"C"/"R" + "T"/"M"/"B"
	YAlign      string // what y refers to: "text", "baseline", "font"
	FixBounds   bool   // prevent text from going outside the video frame
}

Layout controls multi-line text arrangement.

type Oscillation

type Oscillation struct {
	Amplitude float64 // max displacement from center
	Frequency float64 // cycles per second
	StartTime float64
	EndTime   float64
	Decay     float64 // damping factor (0 = no decay, higher = fades faster)
}

Oscillation creates periodic motion (shake, wiggle, pulse).

func (Oscillation) ToExprForTest

func (o Oscillation) ToExprForTest(timeVar string) string

ToExprForTest returns the oscillation expression for testing.

type PadParams

type PadParams struct {
	Width  int
	Height int
	X      int
	Y      int
}

PadParams holds parameters for the pad filter.

type PixelFormat

type PixelFormat string
const (
	PixelFormatRGBA     PixelFormat = "rgba"
	PixelFormatRGB      PixelFormat = "rgb"
	PixelFormatYUV420P  PixelFormat = "yuv420p"
	PixelFormatYUVA420P PixelFormat = "yuva420p"
	PixelFormatYUV422P  PixelFormat = "yuv422p"
	PixelFormatYUV444P  PixelFormat = "yuv444p"
)

type Position

type Position struct {
	X string
	Y string
}

Position defines where a video is placed when used in a CompositeClip. X and Y are FFmpeg expressions (e.g. "(W-w)/2", "0", "100").

func CenterPosition

func CenterPosition() Position

CenterPosition returns a position that centers the overlay on the background.

func TextBottomCenter

func TextBottomCenter() Position

TextBottomCenter returns a position at the bottom center.

func TextBottomLeft

func TextBottomLeft() Position

TextBottomLeft returns a position at the bottom-left corner.

func TextBottomRight

func TextBottomRight() Position

TextBottomRight returns a position at the bottom-right corner.

func TextCenter

func TextCenter() Position

TextCenter returns a position that centers the text on the video.

func TextTopCenter

func TextTopCenter() Position

TextTopCenter returns a position at the top center.

func TextTopLeft

func TextTopLeft() Position

TextTopLeft returns a position at the top-left corner with 10px margin.

func TextTopRight

func TextTopRight() Position

TextTopRight returns a position at the top-right corner.

func TopLeftPosition

func TopLeftPosition() Position

TopLeftPosition returns a position at the top-left corner.

type Progress

type Progress struct {
	// Percentage of encoding completed (0.0 – 100.0).
	Percentage float64
	// Current output timestamp in seconds.
	OutTime float64
	// Total expected duration in seconds.
	TotalDuration float64
	// Encoding speed relative to real-time (e.g. 1.5 means 1.5× real-time).
	Speed float64
	// Current encoding bitrate string (e.g. "1024.5kbits/s").
	Bitrate string
	// Current frame number being encoded.
	Frame int64
	// Frames per second the encoder is running at.
	FPS float64
	// Whether encoding has finished.
	Done bool
	// ElapsedSeconds is wall-clock time since encoding started (set by run loop).
	ElapsedSeconds float64
	// ExpectedTotalSeconds is estimated total time; ETA remaining = ExpectedTotalSeconds - ElapsedSeconds.
	ExpectedTotalSeconds float64
}

Progress holds real-time encoding progress reported by FFmpeg.

type ScaleParams

type ScaleParams struct {
	Width  int // pixels, use -1 to preserve aspect when Height set
	Height int // pixels, use -1 to preserve aspect when Width set
}

ScaleParams holds parameters for the scale filter.

type Shadow

type Shadow struct {
	X     int    // horizontal offset (default: 0)
	Y     int    // vertical offset (default: 0)
	Color string // shadow color (default: "black")
}

Shadow controls the drop shadow behind text.

type Stroke

type Stroke struct {
	Width int    // outline thickness in pixels (default: 0)
	Color string // outline color (default: "black")
}

Stroke controls the outline/border around each glyph.

type TextClip

type TextClip struct {
	// Content
	Text     string // text string to draw (required if TextFile is empty)
	TextFile string // path to text file (alternative to Text)

	// Font -- FontFamily is auto-detected:
	//   ends with .ttf/.otf/.woff or contains path separator -> fontfile
	//   otherwise -> font family name via fontconfig
	FontFamily string // e.g. "Arial", "Sans", or "/path/to/font.ttf"
	FontSize   int    // font size in pixels (default: 24)
	FontColor  string // "white", "0xFF0000", "black@0.5" (default: "white")

	// Position & Timing
	Position  Position // X, Y as FFmpeg drawtext expressions
	StartTime float64  // when text appears in seconds (0 = from start)
	EndTime   float64  // when text disappears in seconds (0 = until end)

	// Opacity
	Opacity float64 // 0.0 (transparent) to 1.0 (opaque), default 1.0

	// Appearance sub-structs
	Background Background
	Stroke     Stroke
	Shadow     Shadow
	Layout     Layout

	// Advanced
	TextShaping bool          // enable RTL/Arabic text shaping (default: true)
	Expansion   TextExpansion // text expansion mode (default: ExpansionNormal)

	// Animations (if set, override static Position/Opacity)
	AnimatePosition *AnimatedPosition // animated X,Y position
	AnimateOpacity  *Animation        // animated alpha (0-1)
	Typewriter      *TypewriterParams // character-by-character reveal
}

TextClip represents a text overlay to be drawn on a video.

type TextExpansion

type TextExpansion string

TextExpansion controls how text is expanded in the drawtext filter.

const (
	ExpansionNone   TextExpansion = "none"
	ExpansionNormal TextExpansion = "normal"
)

type TimeRange

type TimeRange struct {
	Start float64
	End   float64
}

TimeRange represents a start and end time in seconds.

type Transition

type Transition string

Transition defines the type of crossfade between two clips.

const (
	TransitionFade       Transition = "fade"
	TransitionFadeBlack  Transition = "fadeblack"
	TransitionFadeWhite  Transition = "fadewhite"
	TransitionWipeLeft   Transition = "wipeleft"
	TransitionWipeRight  Transition = "wiperight"
	TransitionWipeUp     Transition = "wipeup"
	TransitionWipeDown   Transition = "wipedown"
	TransitionSlideLeft  Transition = "slideleft"
	TransitionSlideRight Transition = "slideright"
	TransitionSlideUp    Transition = "slideup"
	TransitionSlideDown  Transition = "slidedown"
	TransitionCircleCrop Transition = "circlecrop"
	TransitionDissolve   Transition = "dissolve"
	TransitionPixelize   Transition = "pixelize"
	TransitionRadial     Transition = "radial"
	TransitionZoomIn     Transition = "zoomin"
	TransitionDiagTL     Transition = "diagtl"
	TransitionDiagTR     Transition = "diagtr"
	TransitionDiagBL     Transition = "diagbl"
	TransitionDiagBR     Transition = "diagbr"
)

type TransitionParams

type TransitionParams struct {
	Transition Transition
	Duration   float64 // overlap duration in seconds
}

TransitionParams holds parameters for clip-to-clip transitions.

type TypewriterParams

type TypewriterParams struct {
	CharDelay float64 // seconds between each character appearing
	StartTime float64 // when typing starts
	Cursor    string  // cursor character (e.g. "|"), empty = no cursor
}

TypewriterParams configures the typewriter (character-by-character) effect.

type Video

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

Video represents a video file with its properties and processing options

func CompositeClip

func CompositeClip(videos []Video) (*Video, error)

CompositeClip overlays multiple videos on top of each other, similar to MoviePy's CompositeVideoClip. The first video is the background; each subsequent video is overlaid using its Position (defaults to center). Audio from all layers is mixed together with amix.

func Concatenate

func Concatenate(videos []Video) (*Video, error)

func ConcatenateWithTransition

func ConcatenateWithTransition(clip1, clip2 *Video, params TransitionParams) (*Video, error)

ConcatenateWithTransition joins two clips with a transition effect. The transition overlaps the end of clip1 with the start of clip2.

func HStack

func HStack(videos []Video) (*Video, error)

HStack stacks videos horizontally from left to right. All input videos must have the same height before calling HStack.

func NewVideoFile

func NewVideoFile(filename string) (*Video, error)

func VStack

func VStack(videos []Video) (*Video, error)

VStack stacks videos vertically from top to bottom. All input videos must have the same width before calling VStack.

func XStack

func XStack(videos []Video, layout string) (*Video, error)

XStack stacks videos according to the provided FFmpeg xstack layout. Example layout: "0_0|w0_0|0_h0|w0_h0"

func (*Video) AddText

func (v *Video) AddText(clip TextClip) (*Video, error)

AddText adds a single text overlay to the video.

func (*Video) AddTexts

func (v *Video) AddTexts(clips []*TextClip) (*Video, error)

AddTexts adds multiple text overlays to the video in one call.

func (*Video) AnimatedBlur

func (v *Video) AnimatedBlur(a Animation) (*Video, error)

AnimatedBlur applies a time-based blur. Start/End are blur radius values (0 = sharp). Uses boxblur for expression support; radius is in pixels (uses floor for integer radius).

func (*Video) AnimatedColor

func (v *Video) AnimatedColor(ac AnimatedColor) (*Video, error)

AnimatedColor applies time-based color adjustments. Nil fields are not animated.

func (*Video) AnimatedRotate

func (v *Video) AnimatedRotate(a Animation) (*Video, error)

AnimatedRotate applies a time-based rotation. Angle is in radians.

func (*Video) AnimatedScale

func (v *Video) AnimatedScale(a Animation) (*Video, error)

AnimatedScale applies a time-based scale. Start/End are scale ratios (1.0 = 100%).

func (*Video) BitRate

func (v *Video) BitRate(bitRate string) *Video

BitRate sets the video bitrate

func (*Video) Blur

func (v *Video) Blur(sigma float64) (*Video, error)

Blur applies a Gaussian blur. Sigma controls blur strength (higher = more blur).

func (*Video) Brightness

func (v *Video) Brightness(brightness float64) (*Video, error)

Brightness adjusts brightness (-1 to 1, 0 = no change).

func (*Video) Codec

func (v *Video) Codec(codec Codec) *Video

Codec sets the video codec

func (*Video) Contrast

func (v *Video) Contrast(contrast float64) (*Video, error)

Contrast adjusts contrast (-1000 to 1000, 1 = no change).

func (*Video) Crop

func (v *Video) Crop(params CropParams) (*Video, error)

Crop crops the video to the specified region.

func (*Video) Cut

func (v *Video) Cut(start, end float64) (*Video, error)

Cut creates a new video segment with specified start and end times (lazy operation) Parameters:

  • start: Start time in seconds (must be >= 0)
  • end: End time in seconds (must be > start and <= video duration)

Returns a new Video object with updated metadata (no file is created until WriteVideo is called)

func (*Video) Duration

func (v *Video) Duration(duration float64) *Video

Duration sets the video duration

func (*Video) Eq

func (v *Video) Eq(params EqParams) (*Video, error)

Eq applies brightness, contrast, saturation, and gamma adjustments.

func (*Video) FadeIn

func (v *Video) FadeIn(duration float64) (*Video, error)

FadeIn applies a fade-in effect for the given duration (seconds) at the start.

func (*Video) FadeOut

func (v *Video) FadeOut(duration float64) (*Video, error)

FadeOut applies a fade-out effect for the given duration (seconds) at the end.

func (*Video) FfmpegArgs

func (v *Video) FfmpegArgs(ffmpegArgs map[string][]string) *Video

FfmpegArgs sets custom FFmpeg arguments

func (*Video) GetAudio

func (v *Video) GetAudio() *Audio

GetAudio returns the audio configuration

func (*Video) GetBitRate

func (v *Video) GetBitRate() string

GetBitRate returns the video bitrate

func (*Video) GetCodec

func (v *Video) GetCodec() string

GetCodec returns the video codec

func (*Video) GetDuration

func (v *Video) GetDuration() float64

GetDuration returns the video duration

func (*Video) GetEndTime

func (v *Video) GetEndTime() float64

GetEndTime returns the end time for subclip

func (*Video) GetFfmpegArgs

func (v *Video) GetFfmpegArgs() map[string][]string

GetFfmpegArgs returns the custom FFmpeg arguments

func (*Video) GetFilenames

func (v *Video) GetFilenames() []string

GetFilenames returns the video filename

func (*Video) GetFps

func (v *Video) GetFps() uint64

GetFps returns the video frames per second

func (*Video) GetFrames

func (v *Video) GetFrames() int64

GetFrames returns the total number of frames in the video

func (*Video) GetHeight

func (v *Video) GetHeight() uint64

GetHeight returns the video height

func (*Video) GetIsTemp

func (v *Video) GetIsTemp() bool

GetIsTemp returns whether this video is a temporary file

func (*Video) GetPixelFormat

func (v *Video) GetPixelFormat() PixelFormat

GetPixelFormat returns the video pixel format

func (*Video) GetPosition

func (v *Video) GetPosition() Position

GetPosition returns the overlay position. Returns center position if none was explicitly set.

func (*Video) GetPreset

func (v *Video) GetPreset() preset

GetPreset returns the video preset

func (*Video) GetStartTime

func (v *Video) GetStartTime() float64

GetStartTime returns the start time for subclip

func (*Video) GetWidth

func (v *Video) GetWidth() uint64

GetWidth returns the video width

func (*Video) GetWithMask

func (v *Video) GetWithMask() bool

GetWithMask returns whether the video has a mask

func (*Video) Grayscale

func (v *Video) Grayscale() (*Video, error)

Grayscale converts the video to grayscale.

func (*Video) HasAudio

func (v *Video) HasAudio() bool

HasAudio returns whether the video has an audio stream

func (*Video) Height

func (v *Video) Height(height uint64) *Video

Height sets the video height

func (*Video) HorizontalFlip

func (v *Video) HorizontalFlip() (*Video, error)

HorizontalFlip flips the video horizontally.

func (*Video) Hue

func (v *Video) Hue(params HueParams) (*Video, error)

Hue adjusts hue and saturation.

func (*Video) Negate

func (v *Video) Negate() (*Video, error)

Negate inverts the colors of the video.

func (*Video) Pad

func (v *Video) Pad(params PadParams) (*Video, error)

Pad adds padding to the video.

func (*Video) PixelFormat

func (v *Video) PixelFormat(pixelFormat PixelFormat) *Video

PixelFormat sets the video pixel format

func (*Video) Preset

func (v *Video) Preset(p preset) *Video

Preset sets the video preset

func (*Video) Pulse

func (v *Video) Pulse(o Oscillation) (*Video, error)

Pulse applies a scale oscillation (zoom in/out effect).

func (*Video) Rotate

func (v *Video) Rotate(angle float64) (*Video, error)

Rotate rotates the video by the given angle in radians.

func (*Video) Saturation

func (v *Video) Saturation(saturation float64) (*Video, error)

Saturation adjusts color saturation (0-3, 1 = no change).

func (*Video) Scale

func (v *Video) Scale(params ScaleParams) (*Video, error)

Scale resizes the video. Use -1 for width or height to preserve aspect ratio.

func (*Video) ScaleRatio

func (v *Video) ScaleRatio(ratio float64) (*Video, error)

ScaleRatio scales video by a ratio multiplier (e.g., 0.5 = half, 2.0 = double). Uses explicit dimensions from video metadata; ensures dimensions are even for codec compatibility.

func (*Video) Sepia

func (v *Video) Sepia() (*Video, error)

Sepia applies a sepia tone effect.

func (*Video) SetAnimatedOpacity

func (v *Video) SetAnimatedOpacity(a Animation) *Video

SetAnimatedOpacity sets the overlay opacity animation for CompositeClip.

func (*Video) SetAnimatedPosition

func (v *Video) SetAnimatedPosition(ap AnimatedPosition) *Video

SetAnimatedPosition sets the overlay position animation for CompositeClip.

func (*Video) SetAudio

func (v *Video) SetAudio(audio Audio) *Video

SetAudio sets the audio configuration

func (*Video) SetEndTime

func (v *Video) SetEndTime(endTime float64) *Video

SetEndTime sets the end time for subclip

func (*Video) SetFilename

func (v *Video) SetFilename(filenames []string) *Video

SetFilename sets the video filename

func (*Video) SetFps

func (v *Video) SetFps(fps uint64) *Video

SetFps sets the video frames per second

func (*Video) SetFrames

func (v *Video) SetFrames(frames uint64) *Video

SetFrames sets the total number of frames in the video

func (*Video) SetIsTemp

func (v *Video) SetIsTemp(isTemp bool) *Video

SetIsTemp marks whether this video is a temporary file

func (*Video) SetPosition

func (v *Video) SetPosition(position Position) *Video

SetPosition sets the overlay position used by CompositeClip.

func (*Video) SetStartTime

func (v *Video) SetStartTime(startTime float64) *Video

SetStartTime sets the start time for subclip

func (*Video) Shake

func (v *Video) Shake(o Oscillation) (*Video, error)

Shake applies a position oscillation (camera shake effect).

func (*Video) Sharpen

func (v *Video) Sharpen(amount float64) (*Video, error)

Sharpen applies an unsharp mask. Amount controls sharpening strength (1.0-5.0 typical).

func (*Video) Speed

func (v *Video) Speed(speed float64, pitch ...float64) (*Video, error)

Speed changes playback speed for both video and audio. Parameters:

  • speed: Playback speed multiplier (e.g. 2.0 = 2x faster, 0.5 = half speed)
  • pitch: Optional. If omitted or 0 or 1, pitch is preserved. Otherwise a multiplier (e.g. 1.5 = higher, 0.5 = lower)

Returns a new Video object with updated metadata (no file is created until WriteVideo is called)

func (*Video) VerticalFlip

func (v *Video) VerticalFlip() (*Video, error)

VerticalFlip flips the video vertically.

func (*Video) Vignette

func (v *Video) Vignette(angle float64) (*Video, error)

Vignette applies a vignette (darkened corners) effect. Angle controls darkness (radians, PI/5 typical).

func (*Video) Width

func (v *Video) Width(width uint64) *Video

Width sets the video width

func (*Video) Wiggle

func (v *Video) Wiggle(o Oscillation) (*Video, error)

Wiggle applies a rotation oscillation.

func (*Video) WithMask

func (v *Video) WithMask(withMask bool) *Video

WithMask sets whether the video has a mask

func (*Video) WriteAudio

func (v *Video) WriteAudio(parms AudioParameters) error

func (*Video) WriteVideo

func (v *Video) WriteVideo(parms VideoParameters) error

WriteVideo processes the video with applied filters and writes to output file

func (*Video) ZoomPan

func (v *Video) ZoomPan(params ZoomPanParams) (*Video, error)

ZoomPan applies a Ken Burns style zoom and pan effect.

type VideoParameters

type VideoParameters struct {
	OutputPath  string
	Threads     uint16
	Codec       Codec
	Fps         uint64
	Preset      preset
	WithMask    bool
	Bitrate     string
	PixelFormat PixelFormat
	// SilentProgress disables the default colored progress bar.
	// Has no effect when OnProgress is set.
	SilentProgress bool
	// OnProgress, when set, replaces the default colored progress bar.
	// Called periodically with encoding progress.
	OnProgress func(Progress)
}

VideoParameters holds configuration for video processing.

By default every encode shows a colored progress bar on stderr. Set SilentProgress to true to suppress it, or set OnProgress to replace the built-in output with your own handler.

type ZoomPanParams

type ZoomPanParams struct {
	Zoom     Animation
	Pan      AnimatedPosition
	Duration float64
	FPS      int
}

ZoomPanParams holds parameters for the ZoomPan (Ken Burns) effect.

Directories

Path Synopsis
tests

Jump to

Keyboard shortcuts

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