Skip to content

Latest commit

 

History

History
64 lines (45 loc) · 1.25 KB

README.md

File metadata and controls

64 lines (45 loc) · 1.25 KB

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