Skip to content

Repository files navigation

Simple ffmpeg wrapper

Big thanks to:

barsanuphe for goexiftool wrapper.

xfrr for goffmpeg wrapper.

Defaults

Wrapper uses ffprobe to get mediafile info, so there is default args:

 ffprobe -show_format -show_streams -pretty -print_format json -hide_banner -i %file_name%

This command produce output in json format, so we can unmarshall it to Info struct.

Defaults for ffmpeg command:

 ffmpeg -y -v error -stats -i %file_name% %out_file_name%

-y for answer yes on file rewrite

-v error verbose with only errors

-stats show transcoding status

-i input file

Example

funcmain(){
// Initializem, err:=ffmpegwraper.NewMediaFile("./test/test.MOV")
iferr!=nil {
panic(fmt.Errorf("Failed get file info : %s", err))
}
// Data from ffprobefmt.Println(m.Info)
// ffmpeg paramsffmpParams:="-ss 00:01:30 -crf 20 -bufsize 4096k -vf scale=1280:800:force_original_aspect_ratio=decrease"out, err:=m.Convert("pre_test.mov", strings.Split(ffmpParams, " "));
iferr!=nil{
panic(fmt.Errorf("Failed convert file : %s", err))
}
// Getting status of transcodingformsg:=rangeout {
fmt.Println(msg)
}
}

-ss flag with arg will be moved befote -i flag

About

Simple golang wrapper for ffmpeg

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages