x264-go 介绍
x264-go 为 Go 语言提供了 H.264/MPEG-4 AVC 编解码的实现,基于 x264 库。包中包含 C 源码。
示例代码:
package main import ( "bytes" "image" "image/color" "image/draw" "github.com/gen2brain/x264-go" ) func main() { buf := bytes.NewBuffer(make([]byte, 0)) opts := &x264.Options{ Width: 640, Height: 480, FrameRate: 25, Tune: "zerolatency", Preset: "veryfast", Profile: "baseline", LogLevel: x264.LogDebug, } enc, err := x264.NewEncoder(buf, opts) if err != nil { panic(err) } img := x264.Newycbcr(image.Rect(0, 0, opts.Width, opts.Height)) draw.Draw(img, img.Bounds(), image.Black, image.ZP, draw.Src) for i := 0; i < opts.Width/2; i++ { img.Set(i, opts.Height/2, color.RGBA{255, 0, 0, 255}) err = enc.Encode(img) if err != nil { panic(err) } } err = enc.Flush() if err != nil { panic(err) } err = enc.Close() if err != nil { panic(err) } }
x264-go 官网
https://github.com/gen2brain/x264-go
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。