I get Frames in loop and decode it with ffmpeg getting AVFrame as e result of it.
So I must get neccessary pixel data of frame into char* and give as a callback function's parameter. So how I can generete such char* array? In internet I saw some examples such as:
for(y=0; y<height; y++)
{
fwrite(pFrame->data[0]+y*pFrame->linesize[0], 1, width*3, pFile);
}
or something like this. Is it true? And which size would be my char* ? As I see we write width*3 *height bytes?
Yes that's correct.
This is writing a line of 3byte/pixel (presumably RGB) from the AVFrame->data pointer.
ps. The reason for doing it like this is that the start of each row of data begins on a new 4byte memory boundary - the computer is more efficent at accessing memory in multiples of 32bits (4bytes). So if your pixel size (3bytes) and width aren't a multiple of 4 then you need to do this rather than simply copy
width*height*3
bytes of data.