When planning ahead for this, you record the person in front of an evenly-lit green or blue screen. This makes keying straightforward and practical. Without a background designed for chroma keying, you'll have to animate masks over the person, tweaking them on every single frame. This is called rotoscoping [link], and it's laborious. Ae has some tools called Roto Brush, Refine Edge, and Refine Matte which can help quite a lot with this task. Be sure to read the Roto Brush documentation [link] before you start, as it can be a bit tricky to use.