liv

package module
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 19 Imported by: ? modules, 0 packages

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

ffmpeg

friendly ffmpeg wrap for go.

  • ffmpeg
    • 多路输入
      • -i 输入文件
      • -ss 开始时间
      • -t 持续时间
    • 复合滤波器
      • 多路输入
      • 多路输出
    • 多路输出
      • -map 选择流
      • -metadata kv
      • -c 流编码方式
      • -threads 多线程转码
      • -max_muxing_queue_size 容器封装队列大小(默认4086)
      • -movflags(默认faststart)
      • 输出文件
支持的滤镜
  • 视频属性video:
    • 缩放clip:可以设置width和height,不设置默认-2(自适应偶数长度)
  • 音频属性audio:
    • 码率vb:设置音频的最大码率,如果高于原音频码率则使用原音频码率
  • 加水印logo:
    • 可以设置水印图片,水印位置,水印位置偏移量,水印图片缩放大小,均支持绝对像素和百分比
    • 只可以全程加水印,不可以指定时间段
  • 去水印delogo:
    • 指定一个开始时间,在这个时间点之后遮一个rect列表
  • 裁剪clip:
    • 指定开始时间和持续时长,持续时长不指定的话默认到视频结束
  • 添加元信息metadata:
    • 指定一组key-value
    • key仅支持部分字符串,可用的字符串可以看ffmpeg

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrParamsInvalid  = errors.New("params is invalid")
	ErrParamsInvalid2 = errors.New("interval required when frame_type is 1(normal frame)")
)

Functions

func ConcatFile added in v0.8.5

func ConcatFile(files []string, localPath string) error

Types

type Audio

type Audio struct {
	Codec   string `json:"codec,omitempty"`
	Bitrate int32  `json:"bitrate,omitempty"`
}

type Clip

type Clip struct {
	Seek     float32 `json:"seek,omitempty"`
	Duration float32 `json:"duration,omitempty"`
}

type ConcatParams added in v0.7.0

type ConcatParams struct {
	Infiles    []string
	ConcatFile string // eg. mylist.txt
	Outfile    string
	Duration   float32
}

type ConvertContainerParams added in v0.3.0

type ConvertContainerParams struct {
	InFile   string
	OutFile  string
	Metadata []*KV
	Threads  int32
}
type Delogo struct {
	SS   float32    `json:"ss,omitempty"`
	Rect *Rectangle `json:"rect,omitempty"`
}

type ExtractAudioParams added in v0.5.0

type ExtractAudioParams struct {
	Infile  string
	Outfile string
}

type Filters

type Filters struct {
	Container string    `json:"container,omitempty"`
	Metadata  []*KV     `json:"metadata,omitempty"`
	Video     *Video    `json:"video,omitempty"`
	Audio     *Audio    `json:"audio,omitempty"`
	Clip      *Clip     `json:"clip,omitempty"`
	HLS       *HLS      `json:"hls,omitempty"`
}

type HLS

type HLS struct {
	HLSSegmentType     string `json:"hls_segment_type,omitempty"`
	HLSFlags           string `json:"hls_flags,omitempty"`
	HLSPlaylistType    string `json:"hls_playlist_type,omitempty"`
	HLSTime            int32  `json:"hls_time,omitempty"`
	MasterPlName       string `json:"master_pl_name,omitempty"`
	HLSSegmentFilename string `json:"hls_segment_filename,omitempty"`
}

type KV added in v0.4.5

type KV struct {
	K string `json:"k,omitempty"`
	V string `json:"v,omitempty"`
}
type Logo struct {
	File string  `json:"file,omitempty"`
	Pos  string  `json:"pos,omitempty"`
	Dx   float32 `json:"dx,omitempty"`
	Dy   float32 `json:"dy,omitempty"`
	LW   float32 `json:"lw,omitempty"`
	LH   float32 `json:"lh,omitempty"`
}

func (*Logo) NeedScale added in v0.4.0

func (l *Logo) NeedScale() bool

type MergeParams added in v0.5.0

type MergeParams struct {
	FramesInfile string
	VideoInfile  string
	AudioInfile  string
	Filters      *Filters
	Outfile      string
}

type Option added in v0.3.0

type Option func(*options)

func FFmpegOptions

func FFmpegOptions(ffmpegOpts ...ffmpeg.Option) Option

func FFprobeOptions

func FFprobeOptions(ffprobeOpts ...ffprobe.Option) Option

type Point added in v0.3.3

type Point struct {
	X float32 `json:"x,omitempty"`
	Y float32 `json:"y,omitempty"`
}

type Rectangle

type Rectangle struct {
	X float32 `json:"x,omitempty"`
	Y float32 `json:"y,omitempty"`
	W float32 `json:"w,omitempty"`
	H float32 `json:"h,omitempty"`
}

矩形框

type SVGAnnotation added in v0.3.3

type SVGAnnotation struct {
	Type        string   `json:"type,omitempty"`
	Stroke      string   `json:"color,omitempty"`
	Text        string   `json:"text,omitempty"`
	Points      []*Point `json:"points,omitempty"`
	FromPoint   *Point   `json:"from_point,omitempty"`
	ToPoint     *Point   `json:"to_point,omitempty"`
	StrokeWidth int32    `json:"stroke_width,omitempty"`
	FontSize    int32    `json:"font_size,omitempty"`
}

type SVGMarkParams added in v0.3.3

type SVGMarkParams struct {
	Infile      string
	Outfile     string
	StartTime   float32          `json:"start_time,omitempty"`
	Annotations []*SVGAnnotation `json:"annotation,omitempty"`
}

type Snapshot added in v0.3.0

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

func NewSnapshot added in v0.3.0

func NewSnapshot(opts ...Option) *Snapshot

func (*Snapshot) SVGMark added in v0.3.3

func (ss *Snapshot) SVGMark(ctx context.Context, params *SVGMarkParams) error

func (*Snapshot) Simple added in v0.3.0

func (ss *Snapshot) Simple(ctx context.Context, params *SnapshotParams) error

func (*Snapshot) Sprite added in v0.3.3

func (ss *Snapshot) Sprite(ctx context.Context, params *SpriteParams) error

type SnapshotParams added in v0.3.0

type SnapshotParams struct {
	Infile  string
	Outfile string

	// 0-仅关键帧截图 1-等间隔截图 2-指定帧序列截图
	FrameType int32 // 截图类型

	// 等间隔截图
	Interval       int32 // 间隔时间
	IntervalFrames int32 // 间隔帧数

	// 指定帧序列截图
	Frames []int32 // 帧序列

	StartTime float32 // 截图开始时间。截图类型为指定帧序列截图时不建议使用此参数
	Num       int32   // 截图最大数量
	Width     int32
	Height    int32
}

type SnapshotSpec added in v0.3.0

type SnapshotSpec struct{}

func NewSnapshotSpec added in v0.3.0

func NewSnapshotSpec() *SnapshotSpec

func (*SnapshotSpec) CheckSatified added in v0.3.0

func (*SnapshotSpec) CheckSatified(params *SnapshotParams) error

type SpriteParams added in v0.3.3

type SpriteParams struct {
	Infile   string
	Outfile  string
	XLen     int32
	YLen     int32
	Width    int32
	Height   int32
	Interval float32
}

type SubTranscodeParams

type SubTranscodeParams struct {
	Outfile string
	Filters *Filters
	Threads int32
}

type Transcode

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

func NewTranscode

func NewTranscode(opts ...Option) *Transcode

func (*Transcode) Concat added in v0.7.0

func (tc *Transcode) Concat(ctx context.Context, params *ConcatParams) error

多个视频合并成一个

func (*Transcode) ConvertContainer added in v0.3.0

func (tc *Transcode) ConvertContainer(ctx context.Context, params *ConvertContainerParams) error

func (*Transcode) ExtractAudio added in v0.5.0

func (tc *Transcode) ExtractAudio(ctx context.Context, params *ExtractAudioParams) error

ffmpeg -i in.mp4 -vn -c:a copy out.aac

func (*Transcode) MergeByFrames added in v0.5.0

func (tc *Transcode) MergeByFrames(ctx context.Context, params *MergeParams) error

ffmpeg -i in.mp4 -vn -c:a copy out.aac

func (*Transcode) SimpleHLS added in v0.4.0

func (tc *Transcode) SimpleHLS(ctx context.Context, params *TranscodeSimpleHLSParams) error

转hls

func (*Transcode) SimpleJPEG added in v0.3.8

func (tc *Transcode) SimpleJPEG(ctx context.Context, params *TranscodeParams) error

func (*Transcode) SimpleMP3 added in v0.3.8

func (tc *Transcode) SimpleMP3(ctx context.Context, params *TranscodeParams) error

func (*Transcode) SimpleMP4

func (tc *Transcode) SimpleMP4(ctx context.Context, params *TranscodeParams) error

func (*Transcode) SimpleTS added in v0.4.2

func (tc *Transcode) SimpleTS(ctx context.Context, params *TranscodeSimpleTSParams) error

转ts

type TranscodeParams

type TranscodeParams struct {
	Infile string
	Subs   []*SubTranscodeParams
}

type TranscodeSimpleHLSParams added in v0.4.1

type TranscodeSimpleHLSParams struct {
	Infile  string
	Outfile string
	Filters *Filters
	Threads int32
}

type TranscodeSimpleTSParams added in v0.4.2

type TranscodeSimpleTSParams struct {
	Infile  string
	Outfile string
	Filters *Filters
	Threads int32
}

type TranscodeSpec

type TranscodeSpec struct{}

func NewTranscodeSpec

func NewTranscodeSpec() *TranscodeSpec

func (*TranscodeSpec) ConcatSatified added in v0.7.0

func (*TranscodeSpec) ConcatSatified(params *ConcatParams) error

func (*TranscodeSpec) ConvertContainerSatified added in v0.3.0

func (*TranscodeSpec) ConvertContainerSatified(params *ConvertContainerParams) error

func (*TranscodeSpec) ExtractAudioSatified added in v0.5.0

func (*TranscodeSpec) ExtractAudioSatified(params *ExtractAudioParams) error

func (*TranscodeSpec) MergeByFramesSatified added in v0.5.0

func (*TranscodeSpec) MergeByFramesSatified(params *MergeParams) error

func (*TranscodeSpec) SimpleHLSSatified added in v0.4.0

func (*TranscodeSpec) SimpleHLSSatified(params *TranscodeSimpleHLSParams) error

func (*TranscodeSpec) SimpleJPEGSatified added in v0.3.8

func (*TranscodeSpec) SimpleJPEGSatified(params *TranscodeParams) error

func (*TranscodeSpec) SimpleMP3Satified added in v0.3.8

func (*TranscodeSpec) SimpleMP3Satified(params *TranscodeParams) error

func (*TranscodeSpec) SimpleMP4Satified added in v0.3.0

func (*TranscodeSpec) SimpleMP4Satified(params *TranscodeParams) error

func (*TranscodeSpec) SimpleTSSatified added in v0.4.2

func (*TranscodeSpec) SimpleTSSatified(params *TranscodeSimpleTSParams) error

type Transcoder

type Transcoder interface {
	Transcode(context.Context, *TranscodeParams) error
}

type Video

type Video struct {
	Codec     string  `json:"codec,omitempty"`
	Width     int32   `json:"width,omitempty"`
	Height    int32   `json:"height,omitempty"`
	Short     int32   `json:"short,omitempty"`
	FPS       string  `json:"fps,omitempty"`
	Crf       int32   `json:"crf,omitempty"`
	WZQuality float32 `json:"wz_quality,omitempty"`
	Bitrate   int32   `json:"bitrate,omitempty"`
	GOP       int32   `json:"gop,omitempty"`
	PTS       string  `json:"pts,omitempty"`
	APTS      string  `json:"apts,omitempty"`
	PixFmt    string  `json:"pix_fmt,omitempty"`
}

type VideoFilter

type VideoFilter any

Directories

Path Synopsis
examples
ffcut/common command
ffcut/renderer command
ffmpeg/amix command
ffmpeg/concat command
ffmpeg/fake command
ffmpeg/hls command
ffmpeg/hls_key command
ffmpeg/loudnorm command
ffmpeg/mask command
ffmpeg/two_pass command
ffprobe command
ffvmix command
Package ffcut defines the versioned, renderer-independent FFcut timeline protocol.
Package ffcut defines the versioned, renderer-independent FFcut timeline protocol.
renderer
Package renderer renders validated ffcut projects with FFmpeg.
Package renderer renders validated ffcut projects with FFmpeg.
fftool
Package ffvmix defines persistent mix templates and their one-time local asset compilation.
Package ffvmix defines persistent mix templates and their one-time local asset compilation.
constraints
Package constraints defines the pure, read-only FFVMix constraint boundary and the built-in history constraints.
Package constraints defines the pure, read-only FFVMix constraint boundary and the built-in history constraints.
pkg

Jump to

Keyboard shortcuts

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