The merger of Viacom and CBS is shaping up to be lucrative for its top two execs.

Acting CBS Chief Executive Joe Ianniello, who will be chairman and CEO of CBS at the combined firm, will bank a hefty payout of $70 million when the deal closes. That payout is tied to a provision in his old CBS contract that entitled him to a lump sum if he wasn’t named CEO of ViacomCBS.

Viacom CEO Bob Bakish, who will grab the reins as president and CEO of the combined ViacomCBS, will see his total compensation jump 55 percent to about $31 million a year, according to an SEC filing.

Last week, Viacom and CBS, struck a long-awaited deal to reunite under National Amusements, the holding company of the incapacitated media mogul Sumner Redstone. The $27 billion deal brings together Viacom’s cable channels Nickelodeon, MTV, Comedy Central and movie studio Paramount Pictures, with CBS’ broadcast network and cable channel Showtime.

The deal is expected to close by year’s end. As reported by The Post, it could close within the next three months, given that National Amusements Inc., which owns an 80% stake in both companies, has the power to fast-track the deal’s closing if it doesn’t meet regulatory opposition.

Bakish, whose new contract ends four years after the deal closes, will see his salary rise 3% to $3.1 million,

The CEO is eligible for a $12.4 million bonus, up 77%, as well as a $16 million incentive package, up about 60%.

Bakish will also nab a one-time stock grant of ViacomCBS shares worth $5 million.