I am trying to convert NV12 raw data to H264 using hw encoder of FFMPEG.
to pass raw data to encoder I am passing AVFrame struct using below logic:
uint8_t * buf;
buf = (uint8_t *)dequeue();
frame->data[0] = buf;
frame->data[1] = buf + size;
frame->data[2] = buf + size;
frame->pts = frameCount;
frameCount++;
but using this logic, I am getting, color mismatched H264 data,
Can someone tell me , How to pass buffer to AVFrame data?
Thanks in Advance, Harshil
I solved color mismatch issue by passing correct linesize and data value of AVFrame struct.
Let's say NV12 has YYYYUVUV plane for 4x4 image, then in ffmpeg, we need to pass
linesize[0] = start location of y
linesize[1] = 4 because location of u started at 4 and we dont need to specify linesize[2] because uv are packed.
and also in case of data
data[0] = start location of y
data[1] = 4