Answer by taking a quote from the following article:

Departures (Japanese: okuribito, Hepburn: Okuribito, "one who sends off") is a 2008 Japanese drama film directed by Yojiro Takita and starring Masahiro Motoki, Ryoko Hirosue, and Tsutomu Yamazaki. Loosely based on Coffinman, a memoir by Shinmon Aoki, the film follows a young man who returns to his hometown after a failed career as a cellist and stumbles across work as a nokanshi--a traditional Japanese ritual mortician. He is subjected to prejudice from those around him, including from his wife, because of strong social taboos against people who deal with death. Eventually he earns their respect and learns the importance of interpersonal connections through the beauty and dignity of his work.

Japanese funerals are highly ritualized affairs which are generally--though not always--conducted in accordance with Buddhist rites. In preparation for the funeral, the body is washed and the orifices are blocked with cotton or gauze. The encoffining ritual (called nokan), as depicted in Departures, is rarely performed, and even then only in rural areas. This ceremony is not standardized, but generally involves professional morticians (Na Guan Shi , nokanshi) ritually preparing the body, dressing the dead in white, and sometimes applying make-up. The body is then put on dry ice in a casket, along with personal possessions and items necessary for the trip to the afterlife.  Despite the importance of death rituals, in traditional Japanese culture the subject is considered unclean as everything related to death is thought to be a source of kegare (defilement). After coming into contact with the dead, individuals must cleanse themselves through purifying rituals. People who work closely with the dead, such as morticians, are thus considered unclean, and during the feudal era those whose work was related to death became burakumin (untouchables), forced to live in their own hamlets and discriminated against by wider society. Despite a cultural shift since the Meiji Restoration of 1868, the stigma of death still has considerable force within Japanese society, and discrimination against the untouchables has continued.  Until 1972, most deaths were dealt with by families, funeral homes, or nokanshi. As of 2014, about 80% of deaths occur in hospitals, and preparation of the bodies is frequently done by hospital staff; in such cases, the family often does not see the body until the funeral. A 1998 survey found that 29.5% of the Japanese population believed in an afterlife, and a further 40% wanted to believe; belief was highest among the young. Belief in the existence of a soul (54%) and a connection between the worlds of the living and the dead (64.9%) was likewise common.  Motoki, by then in his early 40s and having built a reputation as a realist, was cast as Daigo. Veteran actor Tsutomu Yamazaki was selected for the role of Sasaki; Takita had worked with Yamazaki on We Are Not Alone (1993). Although the character of Mika was initially planned as being the same age as Daigo, the role went to pop singer Ryoko Hirosue, who had previously acted in Takita's Himitsu (Secret) in 1999. Takita explained that a younger actress would better represent the lead couple's growth out of naivety. In a 2009 interview, Takita stated that he had cast "everyone who was on my wish list".  Motoki studied the art of encoffinment first-hand from a mortician, and assisted in an encoffining ceremony; he later stated that the experience imbued him with "a sense of mission ... to try to use as much human warmth as I could to restore [the deceased] to a lifelike presence for presentation to her family". Motoki then drilled himself by practising on his talent manager until he felt he had mastered the procedure, one whose intricate, delicate movements he compared to those of the Japanese tea ceremony. Takita attended funeral ceremonies to understand the feelings of bereaved families, while Yamazaki never participated in the encoffinment training. Motoki also learned how to play a cello for the earlier parts of the film.  To provide realistic bodies while preventing the corpses from moving, after a lengthy casting process the crew chose extras who could lie as still as possible. For the bath house owner Tsuyako Yamashita, this was not possible owing to the need to see her alive first, and a search for a body double was unfruitful. Ultimately, the crew used digital effects to transplant a still image of the actor during the character's funeral scene, allowing for a realistic effect.  The non-profit organization Sakata Location Box was established in December 2007 to handle on-location matters such as finding extras and negotiating locations. After deciding to shoot in Sakata, Location Box staff had two months to prepare for the eighty members of the film crew. Negotiations were slow, as many local property owners lost interest after learning that the filming would involve funeral scenes; those who agreed insisted that shooting take place outside of business hours.  Toyama was both the setting of Coffinman and Takita's home prefecture, but filming was done in Yamagata; this was largely because the national Nokan Association, headquartered in Hokkaido, had a branch office in Sakata. Some preliminary scenes of snowy landscapes were shot in 2007, and primary filming began in April 2008, lasting 40 days. Locations included Kaminoyama, Sakata, Tsuruoka, Yuza, and Amarume. The NK Agent office was filmed in a three-storey, Western-style building in Sakata built between the mid-Meiji and Taisho periods (1880s-1920s). Originally a restaurant named Kappo Obata, it went out of business in 1998. The Kobayashis' cafe, called Concerto in the film, was located in Kaminoyama in a former beauty salon. From a hundred candidates, Takita chose it for its atmosphere as an aged building with a clear view of the nearby river and surrounding mountain range. The scene of the shooting of the training DVD took place in the Sakata Minato-za, Yamagata's first movie theatre, which had been closed since 2002.  The soundtrack to Departures was by Joe Hisaishi, a composer who had gained international recognition for his work with Hayao Miyazaki and Studio Ghibli. Before shooting began, Takita asked him to prepare a soundtrack which would represent the separation between Daigo and his father, as well as the mortician's love for his wife. Owing to the importance of cellos and cello music in the narrative, Hisaishi emphasized the instrument in his soundtrack; he described the challenge of centring a score around the cello as one of the most difficult things he had ever done. This score was played during shooting, which according to Takita "allowed [the crew] to visualize many of the emotions in the film" and thus contributed to the quality of the finished work.  Upon completion, Takita declared Departures "perfect", and praised the crew for their self-reliance in developing the content and the humble, "hand-made" quality of the film. That the film's initial success depended largely on word-of-mouth was also a source of pride for the director. Coffinman author Shinmon Aoki praised Motoki's performance and the film's ability to show the importance of family and interpersonal connections, despite his disappointment at the dropping of the story's religious aspect.

When and where was Departures filmed?
Some preliminary scenes of snowy landscapes were shot in 2007, and primary filming began in April 2008, lasting 40 days.