A cgo package for rkmpp media library.
Need rockchip/mpp enviorment.
A recommended tutorial is to follow the guidance on ffmpeg-rockchip#Compilation.
pkg-config --cflags rockchip_mpp
go get -u github.com/Tryanks/go-rkcodec
package main
import "C"
import "github.com/Tryanks/go-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
}