Just when I thought I'd had it with Lars von Trier, the brilliant yet monumentally perverse Danish director whose crushing, monotonous ''Dogville'' appeared to bring his obsessions (cruelty, digital ''purity,'' female martyrdom) to a poisonous dead end, he masterminds a movie that's so eager and playful and inspired that it made me a von Trier believer again. In The Five Obstructions, von Trier appears on camera, in all his smiling rogue egotism, to challenge his former mentor Jorgen Leth. In 1967, Leth made a black-and-white short called ''The Perfect Human'' that satirized the cozy hip complacency of the new middle class. The premise of ''The Five Obstructions'' is that Leth will remake his film in five different ways, with von Trier, each time, devising an arbitrary set of rules and restrictions.
As the two sit around von Trier's office, drinking vodka and eating caviar, von Trier first demands that Leth remake his film with no shot lasting longer than 12 frames (roughly half a second). You think, ''How could that possibly work?'' Then Leth goes and does it; he uses von Trier's self-described ''diabolical'' obstruction to craft a gorgeous and resonant film. The rules only get worse from there. Leth is forced to shoot in the red-light district of Bombay, then redo his movie as a cartoon -- a form both men despise. As he rises to each challenge, you realize that von Trier, the most exalted of prankish sadists, has orchestrated the filmmaking equivalent of the story of Job. ''The Five Obstructions'' glories in art, life, and the faith that binds them.