The season of cinematic claustrophobia represented by the trapped-in-an-elevator “Devil” and the trapped-in-a-coffin “Buried” continues with the trapped-in-a-crevice “127 Hours.” But this film distinguishes itself from its predecessors, in the process becoming one of the season’s best, for a few reasons. One is that it’s fact-based. The second is that it’s directed by Danny Boyle, who, working with cinematographer Anthony Dod Mantle, has become a master of using every conceivable device to keep the picture energetic and visually arresting despite the confinement implicit in the narrative. And finally it showcases a performance by James Franco that’s impressive in its range and vividness.

The screenplay by Boyle and Simon Beaufoy is based on the book by Aron Ralston that recounts his five-day ordeal when his right arm was pinned by a dislodged boulder during a rock-climbing weekend alone in the Utah wilds. What he ultimately has to do to extricate himself from the predicament is certainly grisly, though not staged for shocking effect.

Moreover, while much of the running-time is devoted to the hours Ralston spent trying to escape and pondering the mistakes he’s made in his life—giving Franco the chance to do a one-man tour de force that ranges from grimness to poignancy to gallows humor—Boyle, in his usual fashion, caps it all off with a life-affirming message in which Aron learns what’s really important and refuses to give up, no matter what it takes to survive.

Boyle also contrives an exuberant first act that shows Ralston preparing for his trip—skipping a call from his mother in order to get an early start, for example (something he comes to regret)—and a meeting in the desert with two hikers (Kate Mara and Amber Tamblyn) that turns into an interlude of joyous abandon (and, pointedly, the only real human connection Aron has until the close, when he approaches a family of other wilderness lovers for help).

But it isn’t just the script through which Boyle releases the narrative from its natural sense of confinement. He employs the same vibrant, hyperkinetic style that he brought to “Slumdog Millionaire” to this film as well, reveling in startling, virtuoso camera moves not only in the “outdoor” sequences but the long cave scenes as well. Though the protagonist might be stuck in a shaft, Mantle’s camera swirls around and about him constantly.

And just as he unleashes the lens, Boyle gives Franco free rein as well. As an actor Franco’s always had a knowing, self-referential air about him, as though he was watching himself giving a performance and adopting an attitude of ironic self-awareness about it. That’s also the case here, but in this instance it fits the film perfectly, because Ralston himself is presented as kind of a showman, using his camcorder to document his plight even as he passes from an initial reaction of almost bemused incredulity at the mess he’s gotten himself into to serious reflection on his life to a dogged determination to endure. Franco is so convincing in this meaty role because he seems to share the real character’s inclination not just to take risks (though his are of the thespian variety) but to observe himself with the sort of detachment that allows him to recognize his own absurdity.

This is essentially a one-person show in front of the camera, of course, but the giddy Tamblyn and Mara make the most of their brief contributions, and a few others—including Treat Williams as Aron’s father—appear in flashbacks. The major support, however, comes from the technical crew, who help realize Boyle’s vision by bringing crispness and verve to the proceedings. Mantle’s exceptional work is complemented by Jon Harris’ zippy editing—which makes even the interior scenes “move”—and the efforts of the entire production team, who must have been tested especially by filming in the remote Utah locations. A. R. Rahman’s background score is nicely unpredictable.

“127 Hours” closes with some images of the real Ralston, a survivor who hasn’t given up the search that led him into the Utah wilderness in the first place. In lesser hands they might have come across as mawkish, but in the context of what’s preceded them here they’re very satisfying. As is the whole film.