scalarhq/go-fluent-ffmpeg
关于
A Go implementation of fluent-ffmpeg
设计与媒体实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Go Fluent FFmpeg 
A Go version of node-fluent-ffmpeg.
Installation
go get -u github.com/modfy/fluent-ffmpeg
Requirements
You will need FFmpeg installed on your machine, or you can specify a path to a binary:
// Provide an empty string to use default FFmpeg path
cmd := fluentffmpeg.NewCommand("")
// Specify a path
cmd = fluentffmpeg.NewCommand("/path/to/ffmpeg/binary")
Quick Start
Create and run commands using an API similar to node-fluent-ffmpeg:
err := fluentffmpeg.NewCommand("").
InputPath("/path/to/video.avi").
OutputFormat("mp4").
OutputPath("/path/to/video.mp4").
Run()
You could use context to set the timeout:
ctx, cancel := context.WithTimeout(context.Background(), time.Second * 5)
defer cancel()
err := fluentffmpeg.NewCommand("").
InputPath("/path/to/video.avi").
OutputFormat("mp4").
OutputPath("/path/to/video.mp4").
RunWithContext(ctx)
If you want to view the errors/logs returned from FFmpeg, provide an io.Writer to receive the data.
buf := &bytes.Buffer{}
err := fluentffmpeg.NewCommand("").
InputPath("./video.avi").
OutputFormat("mp4").
OutputPath("./video.mp4").
Overwrite(true).
OutputLogs(buf). // provide a io.Writer
Run()
out, _ := ioutil.ReadAll(buf) // read logs
fmt.Println(string(out))
You can also get the command in the form of an exec.Cmd struct, with which you can have better control over the running process. For example, you can conditionally kill the FFmpeg command:
done := make(chan error, 1)
cmd := fluentffmpeg.NewCommand("").
InputPath("./video.avi").
OutputFormat("mp4").
OutputPath("./video.mp4").
Overwrite(true).
Build()
cmd.Start()
go func() {
done <- cmd.Wait()
}()
select {
case <-time.After(time.Second * 5):
fmt.Println("Timed out")
cmd.Process.Kill()
case <-done:
}
FFprobe is also available for use and returns a map[string]interface{} of JSON data:
data := fluentffmpeg.Probe("./video.avi")
Credits
This repo was inspired by node-fluent-ffmpeg and was built upon the work done by @bitcodr in the https://github.com/bitcodr/gompeg
Managed Version
You can deploy this codebase yourself or you an entirely managed api from the creators at https://api.modfy.video
探索相关项目
加载中…