There was no small amount of shock and surprise when it was announced in 2013 that Jason Segel would portray the late author David Foster Wallace in “The End of the Tour,” an adaptation of David Lipsky’s “Although Of Course You End Up Becoming Yourself: A Road Trip With David Foster Wallace.”

To capture the mannerisms of the hulking, shy and frequently bandana-clad writer, Segel read as many of Wallace’s intricate, lengthy tomes as he could. “‘Infinite Jest’ was really the one that I focused on,” he told Variety at the BAMcinemaFest opening Wednesday at the Howard Gilman Opera House. “There is some video of him available, and we also had the luxury of those recordings of those four days from David, so I listened and I watched and I read.”

While many comedic actors use ironic detachment to get laughs, throughout his career, starting with “Freaks and Geeks,” Segel has often mined humor from being too earnest for the room. It’s an artistic approach that helped him find common ground with a writer who famously disdained irony and longed to have an authentic emotional rapport with readers. “I connected with him in that way,” he said, “and I really connected with this very honest question he was asking, which was, ‘Does anyone else feel dissatisfied?'”

Anna Chlumsky, who plays Lipsky’s girlfriend Sarah, wasn’t that familiar with Wallace’s work when she signed on for the film. “When he was so popular, I was 13. I had a lot to catch up on,” but she told Variety that she was excited that the script was written by Pulitzer Prize-winner Donald Margulies, one of her favorite playwrights.

“It was so funny, for me, growing up in the ’90s, you never think of it as a period film, but it was. We had to source costumes from the period, and really think about what was going on in the ’90s in New York at the time, and what was her point of view,” she said. “She’s very much part of the literati. And also, you had to uncover what she felt about her relationship,  because that’s really her place in this story, is her relationship with David Lipsky and how much she supports him.”

In order to get the period details right, director James Ponsoldt told Variety that he and his costume designer “obsessed over everything, most specifically what these guys wore, but also everybody around them,” noting that he paid particular attention to the music he selected; the soundtrack is filled with deep cuts from R.E.M. but also a plot-appropriate Alanis Morissette song. “It was a fine line of not wanting to become kitsch or parody, but getting the details right, and removing some details that didn’t age so well,” he said.

The movie is largely a two-hander between Segel and Jesse Eisenberg, who plays Lipsky, as the authors discuss pop culture and the often lonely nature of being a professional writer, as Wallace vacillates between being afraid of how he’ll be portrayed by Lipsky and elation that he’s found someone he can connect with.

“We never wanted it to be a cold, cerebral from-the-neck-up talking-heads movie. We wanted to find the conflict. Where was the tension? Where was the emotion?” Ponsoldt said. “For me, it’s not a story about two smart guys talking, although it is that; it’s an unrequited, platonic love story, from someone who went out to get a story, and started projecting his own issues onto the guy, his own success and self-worth, and it became something much more resonant.”

After the screening, Segel, Ponsoldt and the rest of the cast attended an after-party at the Brooklyn Masonic Temple, where they were feted with  corn dogs, snow cones, Fritos nachos and caramel corn.

A24 releases “The End of the Tour” July 31.