Principal photography on Her took place in mid-2012, with a production budget of $23 million. It was primarily filmed in Los Angeles with an additional two weeks of filming in Shanghai. During production of the film, actress Samantha Morton performed the role of Samantha by acting on set "in a four-by-four carpeted soundproof booth made of black painted plywood and soft, noise-muffling fabric." At Jonze's suggestion, she and Joaquin Phoenix avoided seeing each other on set during filming. Morton was later replaced by Scarlett Johansson. Jonze explained: "It was only in post-production, when we started editing, that we realized that what the character/movie needed was different from what Samantha and I had created together. So we recast and since then Scarlett has taken over that role." Morton is credited as an associate producer. Jonze met Johansson in the spring of 2013 and worked with her for four months. Following the recast, new scenes were shot in August 2013, which were either "newly imagined" or "new scenes that [Jonze] had wanted to shoot originally but didn't."
