Go 中 rkmpp(视频解码器/视频编码器)的绑定
Go to file
2024-03-17 20:03:15 +08:00
buffer.go more impl 2024-03-17 19:50:01 +08:00
cgo.go more impl 2024-03-17 19:50:01 +08:00
CHANGELOG.md init commit 2024-01-04 13:10:52 +08:00
codec.h more impl 2024-03-17 19:50:01 +08:00
err.go more impl 2024-03-17 19:50:01 +08:00
frame.go more impl 2024-03-17 19:50:01 +08:00
go.mod more impl 2024-03-17 19:50:01 +08:00
hdr_meta_com.go more impl 2024-03-17 19:50:01 +08:00
LICENSE init commit 2024-01-04 13:10:52 +08:00
meta.go more impl 2024-03-17 19:50:01 +08:00
mpi_cmd.go more impl 2024-03-17 19:50:01 +08:00
mpi.go more impl 2024-03-17 19:50:01 +08:00
packet.go more impl 2024-03-17 19:50:01 +08:00
README.md Update README.md 2024-03-17 20:03:15 +08:00
task.go more impl 2024-03-17 19:50:01 +08:00
type.go more impl 2024-03-17 19:50:01 +08:00

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
}

Dev Reference

Rockchip_Developer_Guide_MPP