asticode / goav

Golang bindings for FFmpeg libraries

Home Page:https://github.com/asticode/goav

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to fill AVFrame using AvImageFillArrays(...)

ymosleh opened this issue · comments

Hello, I am in the process of learning Go and I am having some problems with the type conversion between Go and C.
Normally, in C I would do something like this:

av_image_fill_arrays(frame->data, frame->linesize, (uint8_t*)imgBuffer, codecCtx->pix_fmt, codecCtx->width, codecCtx->height, 1);
avcodec_send_frame(codecCtx, frame)
......

How would you translate the above to use AvImageFillArrays(...) and set the AVFrame data buffer with uncompressed frames? Also, are there any good examples of using goav for encoding?

Thanks for the help.

How would you translate the above to use AvImageFillArrays(...) and set the AVFrame data buffer with uncompressed frames?

The way I'd do it is :

f := avutil.AvFrameAlloc()
i := avutil.AvAllocateImageBuffer(8)
avutil.AvImageFillArrays([8]*uint8{f.Data()}, [8]int32{int32(f.Linesize())}, b, ...)

Also, are there any good examples of using goav for encoding?

You can check out astiencoder which is a GO encoder framework I've implemented.

Perfect! Thanks so much for the help! Really appreciate it! 👍