WHEN Terry Winter was producing episodes of “The Sopranos” ten years ago, his film crew hared all over New Jersey shooting in and around butchers' shops, family homes and strip clubs. For his new series, Mr Winter has a world of his own. “Boardwalk Empire”, like “The Sopranos”, is a gangster drama made by HBO, a subscription-television company—but it is a period piece shot on a purpose-built 300-foot-long set in Brooklyn. There is a row of artfully tatty shops—a palmist, a photo studio, a display of baby incubators. One side of the set is dominated by a huge blue screen on which images of sky and sea are later superimposed. This is not cheap. The pilot episode of “Boardwalk Empire” cost almost $20m. But it takes more to please TV audiences these days, says Mr Winter.

If so, that is in large part HBO's own fault. For more than a decade it has lavished good, smart product on its viewers, and in the process raised the entire industry's creative game. In the late 1990s HBO pioneered an intelligent, patient style of storytelling that gloried in loose ends and morally ambiguous characters, a style “The Sopranos” came to epitomise. It lost its way around the middle of the last decade, when ambitious dramas like “Deadwood” and “Rome” failed to stick. But it is now back on form. It has three popular, admired dramas in “Boardwalk Empire” (pictured, right) “True Blood” (a vampire series set in Louisiana) and “Game of Thrones” (a fantasy set in the Seven Kingdoms of Westeros). This year HBO received 104 nominations for Emmys (the television Oscars, which will be dished out next month). That's far more than anyone else.

It reliably makes money, too. HBO turned over $4 billion in 2010, estimates SNL Kagan, a research outfit. The previous year it accounted for one-quarter of the operating profit of its parent, Time Warner (which made $4.5 billion in all). Because the media conglomerate, once the world's biggest, has slimmed down, and some of its businesses, such as magazines and DVDs, have been hit by the downturn, HBO has never looked more important to it.

But things are getting tougher. HBO is assailed by competition from old-media peers and new-media upstarts. The pay-TV ecosystem on which it depends is ailing. The way HBO responds to these pressures will shape the television business for years. The outfit that changed the kind of television people watch is poised to determine how they watch it.

HBO has always been innovative. It was the first cable channel to specialise in films—the initials stand for “Home Box Office”—and the first channel to be delivered via satellite. In 1991 HBO pioneered “multiplexing”, a way of distributing multiple channels without using more bandwidth. There are now seven HBO channels in America, including one for children and one in Spanish. Cinemax, an HBO-owned network with 12m American subscribers, has eight channels devoted to films. HBO also shows live boxing matches, the biggest of which are sold on a pay-per-view basis. It has networks in 60 countries and licenses programmes in many more. About 30% of HBO's revenues come from outside America.

The offering for which HBO is now mostly known—original series—developed slowly. In the late 1980s it carried a gleefully unpleasant show called “Tales from the Crypt”. In 1992 it launched “The Larry Sanders Show”, a dyspeptic comedy about a talk-show host. Its first hour-long drama, “Oz”, began in 1997. Soon HBO's content engine was whirring. By the early 2000s it had “The Sopranos”, “Sex and the City” and “The Wire” as well as ambitious mini-series like “Band of Brothers”.

In developing these shows the company made an unusual decision with far-reaching implications. Rather than buying programmes from outside studios, HBO would aim to own its content. The costs of any failures thus fall entirely on the company; but it does not have to share the spoils of success, and it gets to control how its shows are distributed on other channels and on the internet.

Bada Bing!

In America HBO is a premium network, meaning people must pay an additional $15 a month or so to subscribe to it on top of whatever they pay for a hundred-odd “basic” cable channels. That means it need carry no advertising, and can instead carry levels of sex, violence and bad language at which advertisers would blanch. No advertising also means the company focuses on pleasing subscribers rather than amassing huge audiences. “If you're not paying for television, you're not the customer,” says Jeff Bewkes, head of Time Warner. “You're the product.”

Other companies are also exploiting the creative freedom that begins when the ad breaks end. Showtime, a premium network owned by CBS, has put on original shows like “Dexter”, “Nurse Jackie” and “Weeds” that have scooped up plenty of plaudits. Starz, which is run by Chris Albrecht, HBO's former boss, is trying to pull off the same trick. On August 8th it announced a broad agreement to co-produce shows with BBC Worldwide, the British broadcaster's commercial arm, which is moving into producing shows for American television.

Since 2000 Showtime and Starz have each added about 6.7m subscribers in America, more than twice as many as HBO (they have between 18m and 20m subscribers each, compared with HBO's 28m). Showtime and Starz often cost less, and can be more attractive to distributors. When HBO adds a subscriber, it tends to split the new revenue about 50-50 with the cable or satellite broadcaster. The other premium networks are more likely to do flat-rate deals in which the distributors keep all the money from new subscriptions after paying a single licence fee. When choosing which channels to get behind with marketing, the cable companies act accordingly. HBO lost 680,000 subscribers between 2009 and 2010, although its revenues went up, which suggests that many of the viewers who disappeared had not been paying much.

The thick of it If competition from other premium networks were not enough, basic cable networks have also become far more aggressive. Until a few years ago AMC was mostly known for old monster movies. Then it acquired “Mad Men”—a show that had been pitched to HBO and turned down. Soon the awards were rolling in. AMC followed up with “Breaking Bad”, a drama about a methamphetamine cook, and “The Walking Dead”, a zombie series. Channels like FX, Syfy, TNT (which is also owned by Time Warner) and USA have also used original series, sometimes impressive ones, to build their brands. Looking at this competition Richard Plepler of HBO points out that pay-TV is not a zero-sum game: one network's success is not necessarily bad news for another. In a sense the entire industry has won. Talent is migrating from the broadcast networks and film to pay-TV. Showtime has been able to build series around skilled actors. HBO has mostly bet on writers. In high-end television writers can aspire to a level of control, as “showrunners” and producers, that eludes them in cinema. Even by television's standards HBO offers unusual creative freedom. Alan Ball, who won an Oscar for writing “American Beauty” before joining HBO to create “Six Feet Under”, contrasts HBO with the “gulag” of broadcast television. He remembers flurries of “notes” from network executives which squeezed the original ideas out of his scripts. At HBO the notes are fewer and “actually helpful”. Mike Lombardo, the network's head of programming, says he does not recall an occasion on which he has insisted on his view prevailing after a disagreement with a writer or a producer on an important piece of storytelling.

HBO is also more likely than other networks to give programmes a chance to build audiences. It often ostentatiously orders a second season of a show the same day the first episode of the first season is broadcast. Series launched with a lot of publicity but that never find a large audience, such as “In Treatment” or “Treme”, a show about New Orleans, are kept alive for longer than you would expect. Again, this is in contrast to the broadcast networks. Last year just 23% of new broadcast shows were picked up for a second season, according to Michael Nathanson, an analyst at Nomura.

As a result of its patience and commitment HBO has been able to hold on to many of the people who created its iconic shows. Mr Winter and Mr Ball (who after “Six Feet Under” cooked up “True Blood”) are veterans. So is David Simon, who created “The Wire” before moving on to “Treme”. The network continues to draw writing talent in. It has pinched satirist Armando Iannucci from the BBC. Aaron Sorkin, who has enjoyed huge success in network television (with “The West Wing”) and film (“The Social Network”) is developing a new series for HBO. His previous broadcast TV show, “Studio 60”, was cancelled after a single season.

House of cards

Although original series give HBO its identity, much of its schedule is filled with studio films, which tend to land on the network ten months to a year after appearing in cinemas. The company has exclusive deals with three of Hollywood's six major studios—Fox, Universal and Warner Bros—as well as DreamWorks Animation. In 2013 it will add Summit Entertainment, maker of the “Twilight” films. But this roster seems less impressive than it once did, because people now have more ways of watching movies at home.

Netflix, which sends customers rental DVDs through the post as well as streaming films and television shows to laptops, games consoles and iPads, has quickly grown into a serious competitor to HBO's film offerings. It had 9.4m subscribers at the end of 2008; it now has more than 25m: it should pass HBO next year, if not sooner. The firm has already played havoc with the DVD business, once Hollywood's main source of profits, by making it convenient to rent films as opposed to buying them. Cable channels are its next targets.

On July 12th Netflix announced a new pricing structure. From September existing customers, who now pay $9.99 per month for DVDs through the post (getting one disc at a time) and unlimited streaming of mostly older programmes and films, will instead be offered DVDs and streaming for $7.99 each. If they want both they must pay $15.98. New customers already face the new prices. The firm assumes that customers will gravitate to streaming.

In one way this is good news for HBO and similar companies. American media law allows Netflix to offer DVDs for rental as soon as they go on sale in shops (generally about four months after the title is first released in cinemas). But if Netflix wants to stream a film or a TV show it must do a separate deal with the company that produced it. Some studios make Netflix wait years to stream their content and others—including HBO—refuse to let Netflix have it at all. When Netflix offered cheap subscriptions that covered both discs and streaming, this problem could be finessed: a customer who wanted to catch up with the previous season of “True Blood” could simply rent the DVDs. The company also has clever algorithms with which to direct customers to available films and TV shows likely to interest them, and in so doing make the gaps in its catalogue less noticeable. But relying more on streaming will inevitably make the gaps more apparent.

Curb your enthusiasm

If the move to streaming makes it harder for Netflix to sneak around media firms like HBO, though, it will be increasingly capable of challenging them head-on. Its new pricing structure will bring it more money even if people just plump for streaming, because the company will no longer have to pay postal costs. This will let it spend more on content, increasing the prices it can offer recalcitrant studios for streaming rights. It is also starting to spend money on content of its own, and apparently making an HBO-ish bet on quality. Its first television show, “House of Cards”, will be produced by David Fincher, Mr Sorkin's partner on “The Social Network”, and star Kevin Spacey, who led the cast of HBO's Emmy-winning movie “Recount”.

While Netflix competes for upmarket, technologically minded viewers, a humbler challenge is growing. One of the unofficial rules of American media is that pay-television bills always rise. The media companies that own the channels—especially sports channels—constantly demand more money from the cable and satellite outfits that distribute them. The broadcast networks, which used to offer distributors their channels free of charge, now ask for ever larger “retransmission fees”. Negotiations frequently turn ugly, with channels going dark as discussions fail. The eventual cost increases are passed on to consumers. Pay-TV revenue per user rose by just over 5% a year from 2005 to 2010, from $59.82 per month to $77.43, according to Bernstein Research.

These price increases are being driven through at a time when about 45m Americans receive food stamps and unemployment stands at 9.1%—not much below the 10.1% peak in October 2009. The economic slump has hit large swathes of the American working class—a problem for an industry that sells to some 85% of American households. Data from GfK MRI, a research firm that conducts a large survey, suggest that 17% of HBO's subscribers come from the poorest one-fifth of the population by income and 18% come from the second-poorest quintile.

In 2010 the proportion of America's population that pays for television dropped for the first time, with the losses apparently concentrated among the poorest customers. Craig Moffett of Bernstein Research estimates that the loss of subscribers accelerated in the second quarter of this year. As he points out, the poor are not choosing between pay-television and Netflix's streaming service. They are choosing between pay-television and a third meal.

HBO did not cause the rise in the price of basic-cable packages. But because it is sold as an add-on, other channels are in effect increasing its price. Imagine a supermarket where, in order to buy the item you really want, you first have to buy almost everything else in the shop. Now imagine the price of all those other items is constantly rising.

There is no easy solution to this problem. But HBO has a strategy. It has gradually rolled out HBO Go, an online video service which makes many shows and films available on-demand to anybody who can prove they subscribe to the network. HBO can do this because it owns its programmes. It is promoting the service heavily, occasionally putting popular programmes online before they air on cable.

The short-term goal is to reduce what businesses based on subscription call “churn”. Although the number of HBO subscribers is broadly flat at around 28m, about 10m households drop the service each year, with the same number signing up. The company aims to persuade the average subscriber to stay longer. Hooking people on HBO Go should help. “It's like anything else in life,” says Eric Kessler, a co-president of HBO. “If you use it a lot, you're likely to keep it.” Free online access may hit sales of DVDs a bit, but Mr Kessler isn't too worried: income from subscriptions dwarfs the company's DVD revenues.

Beyond the wire

In future HBO Go could allow the network to bypass the entire pay-TV system. For now, going “over the top” in this way makes no sense, says Bill Nelson, HBO's chief executive. There are roughly 105m multichannel TV households in America, of which 77m do not subscribe to HBO. By contrast, he reckons, there are only about 3m households with broadband connections and reasonable amounts of money but no multichannel TV. It makes sense to go after the bigger group. But this may change. “Let's assume that in ten years' time there has been a significant shift away from multichannel subscriptions,” says Mr Nelson. “In that environment, HBO may reconsider its position.”