Skip to content

A broken bindings for rkmpp (Video Decoder / Video Encoder) in Go

License

Notifications You must be signed in to change notification settings

Tryanks/go-rkcodec

Repository files navigation

Go rkcodec

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

Usage

Install

go get -u github.com/Tryanks/go-rkcodec

Code

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
}

Dev Reference

Rockchip_Developer_Guide_MPP

About

A broken bindings for rkmpp (Video Decoder / Video Encoder) in Go

Resources

License

Stars

Watchers

Forks

Packages

No packages published