Tyler Perry, the writer, director, producer, playwright and actor, has signed a long-term deal with Viacom that could help the fortunes of that embattled media conglomerate.

Mr. Perry, best known for his “Madea” movie series, has agreed to produce 90 episodes annually of original drama and comedy series for BET and other Viacom networks. Viacom will also have exclusive distribution rights to Mr. Perry’s short-form video content, and its Paramount Pictures group will have “first-look” rights on his feature-film concepts.

The film deal starts immediately, but the TV and video components won’t begin until 2019, when Mr. Perry’s agreement with OWN: Oprah Winfrey Network expires. The Viacom deal is to run through 2024.

Viacom suffered a particularly bruising 2016: A proposed merger with CBS was cast aside, and a fight for control of the company led to the ouster of its longtime chief executive Philippe Dauman. Shari E. Redstone, the daughter of the media mogul Sumner M. Redstone, emerged triumphant from the battles to become vice chairwoman of Viacom’s board of directors and vice chairwoman of the board at CBS. This year a new chief executive, Robert M. Bakish, outlined a plan to embrace the company’s flagship brands, including BET. The deal with Mr. Perry is a way to capitalize on the star power he brought to OWN.