Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gen2brain/x264-go
Go bindings for x264
https://github.com/gen2brain/x264-go
encoder golang x264
Last synced: 4 days ago
JSON representation
Go bindings for x264
- Host: GitHub
- URL: https://github.com/gen2brain/x264-go
- Owner: gen2brain
- License: gpl-2.0
- Created: 2018-02-15T23:35:50.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-22T18:21:36.000Z (about 2 months ago)
- Last Synced: 2024-11-21T21:03:25.522Z (21 days ago)
- Topics: encoder, golang, x264
- Language: Go
- Size: 2.75 MB
- Stars: 214
- Watchers: 8
- Forks: 44
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: COPYING
- Authors: AUTHORS
Awesome Lists containing this project
- awesome-repositories - gen2brain/x264-go - Go bindings for x264 (Go)
README
## x264-go
[![Build Status](https://github.com/gen2brain/x264-go/actions/workflows/build.yml/badge.svg)](https://github.com/gen2brain/x264-go/actions)
[![GoDoc](https://godoc.org/github.com/gen2brain/x264-go?status.svg)](https://godoc.org/github.com/gen2brain/x264-go)
[![Go Report Card](https://goreportcard.com/badge/github.com/gen2brain/x264-go?branch=master)](https://goreportcard.com/report/github.com/gen2brain/x264-go)`x264-go` provides H.264/MPEG-4 AVC codec encoder based on [x264](https://www.videolan.org/developers/x264.html) library.
C source code is included in package. If you want to use external shared/static library (i.e. built with asm and/or OpenCL) use `-tags extlib`
### Installation
go get -u github.com/gen2brain/x264-go
### Build tags
* `extlib` - use external x264 library
* `pkgconfig` - enable pkg-config (used with extlib)### Examples
See [screengrab](https://github.com/gen2brain/x264-go/blob/master/examples/screengrab/screengrab.go) example.
### Usage
```go
package mainimport (
"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)
}
}
```## More
For AAC encoder see [aac-go](https://github.com/gen2brain/aac-go).