animax

package module
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 12 Imported by: 0

README

Animax

Description

Animax is a Go (Golang) public module created in hope of making video/audio editing on Golang become a much easier task for everyone. Unlike any other binders/wrappers, animax uses graph + rules in order to maximize effiency in video editing especially for clipping videos/audios by choosing when to re-encode or not depending on the effects you use.

Installations

Animax heavily relies on FFMPEG. To run Animax you would first have to install FFMPEG and add it to your environment path.

  1. Instructions on how to install FFMPEG can be found on this link: How to Install FFmpeg
  2. go get "github.com/pichan321/animax"
Documentation

https://pkg.go.dev/github.com/pichan321/animax

Usage
Video
Load Video
	video, err := animax.LoadVideo("shin.mp4")
	if err != nil {
		panic(err)
	}
Apply effects

Effects can be applied as many as you want on a particular video. Trim effects will always be prioritized and executed first regardless of when it is applied (saving CPU and time).

	video.Trim(200, 300).MuteAudio().Saturate(1.5)
Render

Render method will actually perform render on the video based on all the effects you have chained. Render takes in an output path and video encoding.

The below two lines are equivalent.

	video.Render("output.mp4", animax.VIDEO_ENCODINGS.Best)
	video.Render("output.mp4", "")

Video Render Graph

What happens if trim effect is used only once

A video with only a single trim effect applied will always be re-encoded.

	func main() {
		video, err := animax.LoadVideo("shin.mp4")
		if err != nil {
			panic(err)
		}
		video.Trim(0, 500)
		video.Render("output.mp4", "")
	}

Video Render Graph

What happens if trim effect is used multiple times on a video but not continiously
	func main() {
		video, err := animax.LoadVideo("shin.mp4")
		if err != nil {
			panic(err)
		}
		video.Trim(0, 500).Saturate(1.5).Trim(100, 350).MuteAudio().Trim(0, 150).CropOutTop(100)
		video.Render("output.mp4", "")
	}

Render process graph from above code:

Video Render Graph

Audio
Load Audio
	audio, err := animax.LoadAudio("audio.mp3")
	if err != nil {
		panic(err)
	}
Apply effects

The same as video, you can apply and chain as many effects as you want, but trim effects will always be prioritized and executed first for efficiency.

	audio.Trim(100, 200).Nightcore()
Render
	audio.Render("output.mp3")

Audio Render Graph

Contact:

Emails:

Pichsereyvattana Chan

Documentation

Index

Constants

View Source
const VOLUME_MULTIPLIER_CAP = 100.0

Variables

View Source
var ASPECT_RATIOS = struct {
	Square   float32
	Standard float32

	Shorts float32 //Youtube Shorts, Facebok Reels, Instagram Reels, TikTok Videos
	Videos float32 //Youtube Videos, Facebok Videos, General Videos
}{
	Square:   1.0,
	Standard: 16.0 / 9.0,

	Shorts: 9.0 / 16.0,
	Videos: 16.0 / 9.0,
}
View Source
var AudioGraph []string = []string{
	"-filter_complex",
	"-ss",
	"-af",
	"-vf|-va",
	"-filter:a|-filter:v",
}
View Source
var Logger = GetLogger()
View Source
var VIDEO_ENCODINGS = struct {
	Best       string
	Efficient  string
	Compressed string
}{
	Best:       "libx264",
	Efficient:  "libvpx-vp9",
	Compressed: "libaom-av1",
}
View Source
var VideoGraph []string = []string{
	"-filter_complex",
	"-ss",
	"-aspect",
	"-filter:v|-filter:a",
	"-vf|-va",
}

Functions

func GetLogger added in v1.0.4

func GetLogger() *logrus.Logger

Types

type Args added in v1.0.3

type Args map[string][]subArg

type Audio added in v1.0.3

type Audio struct {
	FileName string
	FilePath string
	// renders [ ][ ]string
	Duration int64
	Format   string
	// contains filtered or unexported fields
}

func LoadAudio added in v1.0.6

func LoadAudio(audioPath string) (audio Audio, err error)

func (*Audio) BassBoost added in v1.0.6

func (audio *Audio) BassBoost() (modifiedAudio *Audio)

func (*Audio) ChangeVolume added in v1.0.4

func (audio *Audio) ChangeVolume(multiplier float64) (modifiedAudio *Audio)

func (Audio) GetExtension added in v1.0.7

func (a Audio) GetExtension() string

func (Audio) GetFilePath added in v1.0.7

func (a Audio) GetFilePath() string

func (Audio) GetFilename added in v1.0.7

func (a Audio) GetFilename() string

func (Audio) GetType added in v1.0.7

func (a Audio) GetType() string

func (*Audio) Nightcore added in v1.0.4

func (audio *Audio) Nightcore() (modifiedAudio *Audio)

func (Audio) Render added in v1.0.6

func (audio Audio) Render(outputPath string) (outputAudio Audio)

func (*Audio) SpeedUp added in v1.0.4

func (audio *Audio) SpeedUp(multiplier float64) (modifiedAudio *Audio)

func (*Audio) Trim added in v1.0.4

func (audio *Audio) Trim(startTime int64, endTime int64) (modifiedAudio *Audio)

type File added in v1.0.3

type File interface {
	GetType() string
	GetFilename() string
	GetFilePath() string
	GetExtension() string
}

type Graph added in v1.0.7

type Graph struct {
	Nodes    map[string][]string
	Ordering []string
}

func GetRenderGraph added in v1.0.7

func GetRenderGraph(graphRules []string) Graph

func (*Graph) AddEdge added in v1.0.7

func (g *Graph) AddEdge(node1 string, node2 string)

func (*Graph) AddNode added in v1.0.7

func (g *Graph) AddNode(node string)

func (Graph) PrintStages added in v1.0.7

func (g Graph) PrintStages(args *Args)

func (*Graph) ProduceOrdering added in v1.0.7

func (g *Graph) ProduceOrdering(args Args, file File) [][]string

topological sort

type TrimSection added in v1.0.3

type TrimSection struct {
	StartTime  int64
	EndTime    int64
	OutputName string
}

type Video added in v1.0.3

type Video struct {
	FileName    string
	FilePath    string
	Width       int64
	Height      int64
	Duration    int64
	AspectRatio string
	Format      string

	IsMuted bool
	// contains filtered or unexported fields
}

func LoadVideo added in v1.0.5

func LoadVideo(videoPath string) (video Video, err error)

Takes in the path of the video to be loaded and returns Video struct containing the video's metadata if the videoPath provided is valid.

func (*Video) Blur added in v1.0.3

func (video *Video) Blur(intensity int16) (modifiedVideo *Video)

func (*Video) ChangeVolume added in v1.0.5

func (video *Video) ChangeVolume(multiplier float64) (modifiedVideo *Video)

func (*Video) Crop added in v1.0.3

func (video *Video) Crop(width int64, height int64, startingPositions ...int64) (modifiedVideo *Video)

func (*Video) CropOutBottom added in v1.0.3

func (video *Video) CropOutBottom(pixels int64) (modifiedVideo *Video)

func (*Video) CropOutLeft added in v1.0.3

func (video *Video) CropOutLeft(pixels int64) (modifiedVideo *Video)

func (*Video) CropOutRight added in v1.0.3

func (video *Video) CropOutRight(pixels int64) (modifiedVideo *Video)

func (*Video) CropOutTop added in v1.0.3

func (video *Video) CropOutTop(pixels int64) (modifiedVideo *Video)

func (Video) GetExtension added in v1.0.7

func (v Video) GetExtension() string

func (Video) GetFilePath added in v1.0.7

func (v Video) GetFilePath() string

func (Video) GetFilename added in v1.0.7

func (v Video) GetFilename() string

func (Video) GetType added in v1.0.7

func (v Video) GetType() string

func (*Video) MuteAudio added in v1.0.3

func (video *Video) MuteAudio() (modifiedVideo *Video)

func (*Video) NewAspectRatio added in v1.0.3

func (video *Video) NewAspectRatio(aspectRatio float32) (modifiedVideo *Video)

func (Video) Render added in v1.0.3

func (video Video) Render(outputPath string, videoEncoding string) (outputVideo Video)

If there exists a file at the specified outputPath, the file will be overwritten.

func (*Video) Resize added in v1.0.3

func (video *Video) Resize(width int64, height int64) (modifiedVideo *Video)

func (*Video) ResizeByHeight added in v1.0.3

func (video *Video) ResizeByHeight(height int64) (modifiedVideo *Video)

func (*Video) ResizeByWidth added in v1.0.3

func (video *Video) ResizeByWidth(width int64) (modifiedVideo *Video)

func (*Video) Saturate added in v1.0.7

func (video *Video) Saturate(multiplier float64) (modifiedVideo *Video)

func (Video) SeekFrame added in v1.0.6

func (video Video) SeekFrame(time int64) float64

func (*Video) Trim added in v1.0.3

func (video *Video) Trim(startTime int64, endTime int64) (modifiedVideo *Video)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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