Record & export gameplay footage at runtime (C++)

Mmmh… I need it to be running on one computer and perfomance is kind of important in my case. I need it to be running at a solid 25fps which turns out to be quite tricky.