A guy walks through a closed second-floor window

That’s not the start of a joke. It was, however, the impetus behind “Sleepwalk with Me,” a one-man stage show, comedy album, book and now feature film from comedian, monologist and now movie director Mike Birbiglia, which opens Friday at the Nickelodeon in Portland.

A few years ago while on tour in Walla Walla, Wash., Birbiglia had a nightmare that a nuclear missile was heading straight for his hotel room. A longtime sufferer of a rare sleep disorder, he dreamed that he leaped out of bed and right through that closed window, landing on the lawn and then in the emergency room, where he received 33 stitches. And some great material for his stand-up act.

Birbiglia’s stand-up, always autobiographical, has a dreamy, sleepy-eyed, everyman persona belying masterful storytelling skills that can turn a seemingly mundane tale into something spellbinding. (He’s like Spalding Gray crossed with Joel Hodgson of “Mystery Science Theater 3000.”)

The stage version of “Sleepwalk with Me” chronicled the comic’s struggles to find his voice, navigate his relationship with his longtime girlfriend (played in the film by Lauren Ambrose of “Six Feet Under”) and cope with a worsening condition that causes him to act out his dreams in often unpredictable ways.

The film version, which was directed by Birbiglia and co-written with Ira Glass (“This American Life”) and others, is a trimmed-down version of the stage production and shaped into a more straightforward narrative in which Birbiglia’s problems stem from his unwillingness to confront things head-on.

He doesn’t fully commit himself to his career, his relationship or, you know, finding a way to make sure he doesn’t jump out a window in his sleep — and finds out the damage that results.

He addresses the camera directly, and his shared understanding of his own foolishness is both funny and sad. “I know,” he assures the audience after a particularly egregious misstep, “I’m in the future also“

Like most one-person shows, it’s a journey of comic and personal growth with some killer jokes throughout, and Birbiglia (or his lightly fictionalized film version, Matt Pandamiglio) lends each development an utterly endearing layer of self-deprecation, even when his actions aren’t particularly laudable.

If there’s a knock on the film, it’s that first-time director Birbiglia doesn’t yet possess comedian Birbiglia’s storytelling virtuosity. His decision to visualize some of his more unusual sleepwalking dreams yields some surreal laughs, but some sequences (like those with his parents, played by the undeniably talented Carol Kane and James Rebhorn) lack the snap of his carefully crafted anecdotes, coming more as service to the film’s streamlined plot.

But I’m being picky. “Sleepwalk with Me” is a moving, hilarious and deeply personal comedy about one guy’s realization that just going along as if everything’s fine is a one-way ticket to, well, lying in your underpants on the glass-strewn lawn of a cheap hotel.