Record a webcam with custom overlay graphics

I’m wondering if anyone knows how to “bake” custom graphics over a stream recorded from a user’s webcam and save the resulting video to a server.

I’ve looked at Flash Media Server and it looks like it’s only possible to record a raw netstream without any baked-on overlay. Does anyone know how to do this?

I need it for a project where a user is able to record themselves interacting with an augmented reality marker and 3D object. I’ve seen this done before, whether it’s done with FMS or some other 3rd party software (Red5?) I’m not sure.