An air of desperation hangs heavy over Jake Kasdan’s “Sex Tape,” a farce that tries so hard to be naughty without becoming tasteless and raunchy without becoming gross that it ends up exhausting its stars as well as the audience, while never achieving the hilarity it’s straining after. When Rob Corddry, of all people, winds up as the most subdued, likable person in the ensemble, you know the movie’s in serious trouble.

The premise is one that served in Jon Favreau’s “Chef” and presumably appeals to those addicted to social media—the danger that something you intend to keep private on line will accidently get posted and go viral. In this instance young Jay (Jason Segel) and Annie (Cameron Diaz) attempt to put some zest back into their increasingly kid-centered marriage by making room for an evening alone, during which they make the titular tape of them trying each and every option recommended in that old favorite, “The Joy of Sex.” It’s intended to be a private affair, of course, but Jay—though he’s supposed to be some sort of tech guy—accidentally posts it to all his old iPads, which he’s given away as gifts to friends and family. So he and his wife have to retrieve all of them to keep their little escapade secret—something made more difficult when a blackmailer posts the footage to a sex-centered website.

The effort involves a bunch of other people—Jay and Annie’s kids Clive (Sebastian Hedges Thomas) and Nell (Giselle Eisenberg); Annie’s mother Linda (Nancy Lenehan); the couple’s best friends Robby and Tess (Corddry and Ellie Kemper) and their son Howard (Harrison Holzer); and, for good measure, a fellow named Hank (Rob Lowe), an executive at the company that’s planning to buy Annie’s blog for their website. What a television sit-com would call a “special guest star” shows up in the last reel as the owner of that sleazy website; the surprise won’t be spoiled here.

Theoretically the idea behind “Sex Tape” could provide the basis for a genuinely funny comedy, but the script by Segel, Kate Angelo and Nicholas Stoller bungles it badly. Problems start early on when we’re asked to accept Segel and Diaz as college students who engage constantly in steamy sex, whenever and wherever. It isn’t nice to point out actors’ ages—after all, the icons of the thirties, forties and fifties regularly played far younger than they actually were, and everybody accepted it as convention. But this movie pretty much begs us to do so when Segel, who’s in his mid-thirties, and Diaz, who’s past forty, are repeatedly saying things as their supposedly college-age selves like “But we’re so young!” Diaz, it must be admitted, wears her decades gracefully—Segel less so. But at least Kasdan could have cut those lines—unless he intended us to laugh at the actors rather than their characters, which is never a good tactic.

But that faux pas pales in comparison to the decision taken about showing the making of the tape itself. One can imagine that being done subtly, leaving a lot to the imagination. Kasdan chooses the bludgeon approach instead. There’s lots of nudity on display here—all of the sniggering, aren’t-we-naughty type that shows just enough to elicit nervous snickers from the older members of the audience. Most of it is provided by Segel, who appears to have inherited Will Ferrell’s penchant for parading a flabby, untanned body before the camera. No full-frontal, of course—only derriere shots. We wouldn’t want to slip past the confines of an “R” rating, of course, even though the picture also lays on some drug humor too.

Then there’s the elaborate episode fashioned for Lowe. Annie has left her iPad—a hand-me-down from her husband—with Hank, and so the two visit him at home to recover it without telling him why. What follows is supposed to be weirdly surrealistic (Hank has some odd predilections) and comically slapstick (Jay has a lengthy run-in with his formidable dog), but it comes across as merely weird. It has to be said, however, that Lowe plays it with a straight-faced intensity that’s almost heroic under the3 circumstances.

Segel and Diaz throw themselves into their roles as well—the taping scene is proof enough of that—but they don’t emerge nearly as unscathed. Their increasingly frantic turns as the story grows more and more complicated become embarrassing in the extreme. By contrast Corddry, usually the most irritating guy in the room, is virtually an oasis of sanity (it doesn’t hurt that Robby gets the best lines, too), and Kemper abets him reasonably well. The kids are mostly fine, though Holzer’s obnoxiousness seems all too real. That unnamed guest star brings a touch of welcome wryness to the disappointingly dumb finale.

“Sex Tape” looks okay—Tim Suhrstedt’s cinematography is discreet when required—but it could hardly be called visually attractive; nor is Michael Andrews’ score as banal as it might be. But overall sending this movie out into the world is about as big an accident as the one Jay and Annie make when their little movie takes to the net.