“Ghost Team,” a supernatural comedy arriving in theaters Aug. 12, features Jon Heder, Justin Long and Amy Sedaris, but the starring role surely belongs to the Long Island property where most of the movie was filmed.

In fact, without the location, the movie might never have existed.

“I said, we’ve got to write a movie that we can shoot for no money. Let’s make it a comedy and we’ll shoot in this location,” says director Oliver Irving, who wrote the film’s story with screenwriter Peter Warren. “That was our starting point.”

“Ghost Team” focuses on Louis (Heder, of “Napoleon Dynamite” and “Blades of Glory”), a young man who runs a copy shop but dreams of someday joining a television team of paranormal investigators. When a customer orders several “no trespassing” signs for his possibly haunted property, Louis decides to visit the place himself with his own team: a mall cop (Long), a supposed tech genius (Paul W. Downs, of Comedy Central’s “Broad City”), a clairvoyant (Sedaris) and a nail-salon worker (Melonie Diaz). David Krumholtz, of the “Harold & Kumar” movies, plays Louis’ sad-sack friend, Stan.

The haunted property looks like something out of “Scooby-Doo,” with a weather-beaten barn, silo and disused sheepherding pen. The whole complex, in Brookhaven, is roughly 75 years old and has been owned by the same family — which wishes to remain anonymous — since 1928.

Irving, a native of England who moved to New York to make his first feature film (2008’s “How to Be,” starring a pre-fame Robert Pattinson), first saw the property in 2012 when he filmed a music video there. That project fell through, but Irving never forgot his first impression of the place. “I said, wow, this location’s great. You could shoot a whole movie here.”

advertisement | advertise on newsday

Last year, that’s exactly what he did. During late October and early November, Irving and his cast gathered at the farm for many a chilly night.

“I had never really spent time on Long Island, but it was a beautiful farm and a beautiful piece of land,” says Heder, who will appear in person Aug. 12 for a screening at Manhattan’s Cinema Village East. “I enjoy shooting independent films, because more often than not you’re shooting on location and you’re cooped up with the rest of the crew and the cast. You get to know each other. And this film was like the epitome of that.”

The only reason the cast didn’t sleep at the farm — Irving’s original idea — is because the space was taken up by gear, costumes and makeup facilities.

“I love camping and I love the cold,” says Heder. “If I’d had a sleeping bag, I would have been game.”