generate thumbnail from AVPacket using api.