mirror of
https://github.com/Tryanks/go-rkcodec.git
synced 2024-05-26 02:56:40 +08:00
Go 中 rkmpp(视频解码器/视频编码器)的绑定
buffer.go | ||
cgo.go | ||
CHANGELOG.md | ||
codec.h | ||
err.go | ||
frame.go | ||
go.mod | ||
hdr_meta_com.go | ||
LICENSE | ||
meta.go | ||
mpi_cmd.go | ||
mpi.go | ||
packet.go | ||
README.md | ||
task.go | ||
type.go |
Go rkcodec
A cgo package for rkmpp media library.
Need rkmpp enviorment.
pkg-config --cflags rockchip_mpp
Usage
Install
go get -u github.com/Tryanks/go-rkcodec
Code
package main
import "C"
import "rkcodec"
func main() {
decoder := rkcodec.NewMppCodec()
decoder.Control(rkcodec.MppDecSetParserSplitMode, C.int(1))
decoder.Init(rkcodec.MppCtxDec, rkcodec.MppCodingAVC)
frame, err := rkcodec.MppFrameInit()
if err != rkcodec.MppSuccess {
panic(err)
}
defer frame.Deinit()
packet, err := rkcodec.NewMppPacket()
if err != rkcodec.MppSuccess {
panic(err)
}
h264NALU := make([]byte, 1024) // H.264 NALU data
packet.SetData(h264NALU)
err = decoder.DecodePutPacket(*packet)
if err != rkcodec.MppSuccess {
panic(err)
}
err = decoder.DecodeGetFrame(frame)
if err != rkcodec.MppSuccess {
panic(err)
}
// Do something with the frame
}