Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Encode YUV/NV12 to PNG using libav

Apr 17, 2021 YUV libav image png

Encode a YUVNV12 to PNG using libav

used this for creating thumbnail out of camera captured nv12 buffers on an soc.

128x64

#include <thumbnail.h>

//Initialize once
thumbnail thumb(inWidth,inHeight,thumbWidth,thumbHeight);

//Save PNG thumbs as required
thumb.savepng ("out.png", Ybuffer, UVbuffer);

// or
thumb.savepng ("out.png", YUVbuffer, YUVbuffer + inWidth*inHeight);