After a see-saw auction that lasted most of two days and nights, a holding company connected to Prana Studios has agreed in principle to acquire bankrupt visual effects studio Rhythm & Hues.

Prana is a visual effects and animation studio with offices in Los Angeles and India. It was founded as an American company but does much of its animation production through an Indian subsidiary.

Prana appeared to be out of the auction Wednesday afternoon but re-entered the bidding following a continuance in the proceedings Thursday. Prana has solid relationships with the majors, as it does animation for studio features. Its credits include “Hoodwinked” for the Weinstein Co. and the upcoming “Planes” for Disney.

The auction turned out to be a difficult and drawn-out process. Early on in the process, Psyop and a Taiwanese bidder with ties to electronics manufacturer Foxconn could not or would not show proof of financing, and were eliminated. Three bidders remained: Prana, Prime Focus and Brave Vision, a Chinese company led by Jiang Yanming, a founder of vfx & post facility Technicolor Beijing, and co-founder, president and largest shareholder of China Lion.

Prana was the next to fall out, it seemed, and Prime Focus and China Lion continued the auction into the night. At around 10:00 p.m. Wednesday it appeared Jiang’s bid had won, but then the auction resumed and continued until 2:00 a.m. Thursday, then broke until late morning.

A final deal remained out of reach even as the scheduled 3:00 p.m. Thursday court date approached. Rhythm & Hues asked for a continuance, pushing the court hearing until 10:00 a.m. Friday and asking for the auction to continue.

From the Annals of Chutzpah: JS Communications, the would-be stalking horse bidder that withdrew at the 11th hour, filed an objection with the court today that slowed down the process. JS had negotiated an large “break-up fee,” insisted on a (almost unheard-of) non-binding stalking horse agreement, then missed the deadline to file its official bid when it couldn’t get assurances that Fox and Universal would send future vfx work to Rhythm & Hues.

JS complained that when it withdrew its bid, R&H dropped the requirement that the next bid be at least $525,000 more than the $17 million stalking horse bid — the bid that JS never delivered. That figure would ensure that JS’s “break-up fee” would be covered. JS’s lawyers were arguing that although it did not provide the stalking horse bid that is supposed to justify the break-up fee, it should get the money anyway.

Talks resumed Thursday evening and Prana emerged the winner of the auction around 9:00 p.m. Paperwork should be final tonight and sealed in a court date tomorrow.

Who the real winners and losers are in this deal remains to be seen.

R&H has been known as one of the most artist-friendly visual effects companies, with generous salaries, vacation time and benefits. Critics of its management complain it was overstaffed, especially in North America. Before its financial troubles R&H was sending 40% of its work abroad. Court documents signal that R&H expects to send much more work to Asia, perhaps 80% or more. Prana is considered a simpatico buyer for R&H but even so the plans to shift much of R&H’s visual effects work overseas are likely to move forward.

But the bigger problem for R&H has been its reliance on just a few clients. Some 80% of its feature vfx business came from Fox and Universal, so it became very vulnerable to changes in their slates and schedules. Then they sneezed — and Rhythm & Hues got galloping pneumonia.

In 2011, Universal cut itsvfx contract for “Snow White and the Huntsman” after staffing and R&D were already in progress. At R&H, which up until then had been financially sound, management realized it would end up with a cash shortfall. Then in 2012 revenues from Fox and Universal, which had been around $90 million over the previous few years, dropped to just $18 million.

Rhythm & Hues wasn’t carrying debt but it was running out of money, so it sought equity investment. It seemed to be on the verge of a deal until Digital Domain went bankrupt last fall. That scared off R&H’s potential investor. Because their revenues and profits are so unpredictable, visual effects studios like R&H generally lack access to short-term bank financing that lets other kinds of similar-sized business smooth over bumps in cash flow.

In January Warner, Fox and Universal had to intervene to keep the doors open at R&H long enough to get their work finished. Warner opposed bankruptcy, and for a time Prime Focus seemed poised to step in and acquire R&H, but that effort stalled when Prime Focus couldn’t assemble the necessary financing. However before today’s auction, Prime Focus was added as a co-debtor in the bankruptcy case, which could mean it had signed to guarantee R&H’s debts. Ironically, only when R&H went into bankruptcy in February did it acquire serious debt: $17 million in debtor in possession loans from Universal and Fox that must be repaid over the next three years.

Given the slender margins in feature film visual effects — figures around 5% seem to be common now — R&H would have to generate over $100 million in revenue over each of the next three years just to repay those loans. That will be difficult, especially if the new ownership moves to cut costs and loses any of the company’s key creatives. However R&H also has divisions for commercials and special-venue projects with more comfortable margins, and they also can contribute to the bottom line.

Throughout the process, hiring has continued unabated at R&H’s new Taiwan facility, which is opening as originally scheduled. It expects to ramp up to 200+ staffers. All of R&H’s facilities outside the U.S. are owned by subsidiaries that were not part of the bankruptcy.