asticode / goav

Golang bindings for FFmpeg libraries
https://github.com/asticode/goav
MIT License
41 stars 16 forks source link

How to fill AVFrame using AvImageFillArrays(...) #3

Closed ymosleh closed 3 years ago

ymosleh commented 3 years ago

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.

asticode commented 3 years ago

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.

ymosleh commented 3 years ago

Perfect! Thanks so much for the help! Really appreciate it! :+1: