Earyl this year, The Daily Show posted a rapid-fire video montage titled “50 Fox News Lies in 6 Seconds.” Such montages, usually riffing on the day’s news, are a staple of The Daily Show and its offshoots, Last Week Tonight With John Oliver and the late, lamented Colbert Report. Mitt Romney, Barack Obama, and Dr. Oz are just a few of the famous figures who have been savaged by these shows’ full-frontal video-clip assaults.

Surely plenty of viewers, after they’ve stopped laughing, have wondered how the shows’ producers regularly manage to find such perfect moments on tight deadlines. Perhaps fans imagine that each show employs a team of professional couch potatoes who watch a staggering amount of video and take encyclopedic notes to guarantee that the just-right clip will always be a play button away. 

In fact, the secret to the ever-ready video clip can be found in a low-rise office building overlooking Buffalo Bayou in Houston’s Sixth Ward that serves as the headquarters of SnapStream. One of the many software companies that have popped up in town in recent years, SnapStream is the brainchild of Rakesh Agrawal, a  Houston native and 1997 Rice University grad who founded the company in 2000. SnapStream’s product sounds simple: a Google-style search engine for television. But making it work is far more difficult than it sounds, because while words and pictures are easily searched on the Internet, broadcast television isn’t. “TV is still ephemeral,” Agrawal says, as we squeeze behind racks of equipment connected by a bird’s nest of coaxial cable in SnapStream’s test room. “It sort of goes out in the ether.”

SnapStream searches through television footage by using software that digs into the closed captioning embedded in every program. Unlike text search, effective video search must recognize the nuances of language. The company’s advanced algorithms can account for misspellings, suffixes, and synonyms; if your search term is “large,” it will also search for “big” and “huge.” Unlike Google, which can pick through pretty much anything on the web, SnapStream can search only those programs that it has recorded. That requires a lot of computing power. “It’s like TiVo on steroids,” Agrawal says. 

And the service isn’t cheap. Four of SnapStream’s regular tuners, with a total of three terabytes of storage and the ability to record four channels at once, will run a client $10,000 for the equipment and $1,500 annually for the service. If you’re looking for something fancier, ten high-definition tuners with a total of nine terabytes of storage run $83,500 for the equipment and $12,525 a year for the service. 

The Daily Show and The Colbert Report’s replacement, The Nightly Show With Larry Wilmore, which are both on Comedy Central, have bought enough SnapStream equipment to record thirty HD channels at once. Producers and writers search the video footage from their desktop computers using simple Boolean search terms, just as everyone does on Google. Editing and clipping the videos they find is as easy as cutting and pasting in Microsoft Word. 

While SnapStream, which has 26 employees, has gained renown for its entertainment clientele, Agrawal says the company has several hundred customers, many in fields such as education, government, and politics. Hillary Clinton was a client during her 2008 presidential campaign, and Agrawal hopes she’ll sign up again for her 2016 run. “You can search for anything in the universe of local TV,” says Alan Bernstein, a spokesman for the Harris County Sheriff’s Office, an early SnapStream customer. “We use it instead of a clipping service.” 

Agrawal founded the company with a very different aim: to help consumers turn their PC into a DVR. The software program he designed for that worked well enough, but Agrawal realized that its appeal was limited—most people didn’t want to watch TV on their desktops. Meanwhile, he had been fielding calls from programs such as Saturday Night Live about whether there was any way to search through videos. No one had the capability to do it well, and Agrawal smelled opportunity. In 2007 he shifted the company’s focus and developed the video search software. Not long after, The Daily Show signed on. Before SnapStream, the show’s interns tediously sifted through recordings looking for clips, guided by text searches of databases such as LexisNexis.

SnapStream recently unveiled a cloud service that costs a flat $300 a month for up to four tuners and one week’s worth of storage. Though there are no plans for a $2.99 SnapStream app for people who just want to put together clever Facebook videos, Agrawal recently introduced a lower-cost product aimed at bloggers that will record two channels for about $100 a month. And the company recently added a function that allows customers to distribute clips easily over Twitter and Facebook. “Social TV may be the next big thing for us,” Agrawal says. So it seems. By mid-April, The Daily Show’s Fox News montage had been viewed millions of times.