MADRID — Most Augusts, Madrid is a ghost capital, as any self-respecting Madrileno has left for the beach. This year, however, its leafy streets welcomed a desultory flow of traffic. Debt-laden from cheap credit, haunted by building stagflation, Spaniards are cutting back. So, too, in film. Spain might not technically be in recession, but broadcasters and pic producers are behaving as if it were.

“Spain’s problem is not that it is suffering more than other European countries, but that it was doing so much better than them before,” wrote the Economist last month. Ditto its film industry. Deregulation — leading to the launch of private TV stations Telecinco, Antena 3 TV and Canal Plus in 1990 — came later to Spain than elsewhere in Western Europe.

So the usual upside to deregulation — increasingly vibrant indie production — only hit Spain recently. Riding a property bubble, developers in the 1990s threw up Spain’s first American-style suburbs. Most needed multiplexes, fueling uninterrupted B.O. growth from 1989 to 2001.

The downturn’s been equally spectacular. From a 2001 high, cinema attendance plummeted 20%, to 116.9 million tickets sold in 2007. Of Europe’s “Big Five,” only Germany, with a 29% drop in admissions, has had it worse. In the first half of this year, ticket sales are off 6 million from last year.

Three factors are at play, argues producer Agustin Almodovar. “Consumer habits are changing: Spaniards increasingly prefer watching films at home. City-center cinemas are closing, cutting outlets for adult-skewed movies. And piracy’s reached extraordinary levels.”

A June study by market research group GfK suggested that 53% of Spanish Internet users — 7.1 million — engaged in unauthorized movie downloads.

Having recently had it so good, Spain’s newly grown industry can’t remember having it so bad. Hard-times strategies vary:

  • Cutting dependence on the Spanish market. Producers of big-name auteurs are looking to recoup largely abroad.

  • Upping genre pic production. Hispano horror is highly sought-after export fare.

  • Practicing microbudgeting. Spain’s Locarno fest offerings “A Dream” and “Blue Bull” cost E110,000 ($61,700) each and were both DV-shot docus. No-string productions won’t turn large profits, but they offer some hope of industrial survival.

  • Throwing in the towel. Many shingles — Continental, Filmanova, Voz Audiovisual in Galicia alone — have migrated to the safer shores of TV production, where profits are guaranteed as part of the budgets.

One factor links these moves: an increasingly acute sense of markets. For Spain — where films have traditionally been greenlit because the money, not the market, was there — that’s little short of a revolution.

Strategies turn on two considerations: nursing new talent and market-mindedness.

“Either you make films with a clear, universal (theme) or for Spain, which occasionally throws out B.O. miracles. But you can’t base a business model on miracles,” says Fernando Bovaira, producer of “Agora.”

“Mediapro works at three levels: new directors; helmers with international profile, such as Isabel Coixet; and international names, such as Woody Allen,” says producer Javier Mendez of Mediapro, which is revving up Coixet’s “Map of the Sounds of Tokyo” and three Allen pics for the next three years.

“We make big-budget films with significant international profile, and movies under $4.5 million, which recoup from Spain,” says Alvaro Augustin, head of Telecinco Cinema, which produced “Pan’s Labyrinth,” “The Orphanage” and “Che.”

Some established producers are adapting. Normally an art pic producer, Tornasol upped the budget and took over as lead producer on Alex de la Iglesia’s “Oxford Murders,” a hit at home and healthy seller abroad.

El Deseo now posts Blog Pedro Almodovar, turning on his “Broken Embraces” shoot, where he chats intimately about Lanzarote, Antonio Banderas and wigs.

From March 6 through Aug. 28, the blog’s had 194,882 hits and has yielded links and copy to viral media worldwide.

Market-mindedness comes easily to a younger generation of producers, often ex-broadcast or multinational execs. Several have hung shingles: Bovaira at Mod Prods. and Edmon Roch and Jordi Gasull at Ikiru and El Toro.

Meanwhile, Escandalo Films, producing first features from ESCAC (film school) students, is emerging as a Barcelona production force.

The gathering market drive isn’t limited to the private sector. Galicia’s Audiovisual Consortium launched a SempreCinema risk equity production fund last year; the Catalan Institute of Cultural Industries (ICIC) is putting up $1.5 million for three to four pics with commercial potential shot in Catalan, such as sci-fier “Eva.”

Pubcaster TVE now focuses part of its $50 million annual Spanish acquisition budget on mainstream projects.

Spain’s market crisis also has accelerated a generational changing of the guard. But challenges remain.

Biz fortunes depend perilously on star auteurs: Almodovar, Amenabar or Trueba, who has returned to directing after an eight-year hiatus with Chile-shot “Victory Dance.”

Star auteur productions have their limitations. “Real auteurs — almost by definition — are rare,” says Bovaira.

Since the ’60s, Spain has proved adept at turning out small dramas, often with social heft, but these films are endangered if pubcasters abandon their public service remit.

“A healthy industry, and country, needs diversity,” says producer Jose Maria Morales. And for most Spanish-language films, overseas markets are hard to crack.

“Thanks to TV market fragmentation, there are more outlets. But in general, deal prices have dropped. You have to sell more simply to maintain sales figures,” says Beatriz Setuain, Imagina Intl. film sales head.

However market savvy a company is, it’s a tough time to launch new dream factories.