Modern factory farms have so much wrong with them, but a starting point is the practice of turning pigs into cannibals.

A video, taken secretly by an undercover worker and scheduled to be released on Thursday by the Humane Society of the United States, pulls back the curtain on the banal brutality of a huge hog operation in Kentucky called Iron Maiden Farms (which declined to comment). The video shows barns filled with hogs jammed so tightly into tiny individual pens that they can’t move, chewing forlornly on the bars that restrain them.

It also shows workers gutting dead piglets and turning their intestines into a purée that is then fed back to the mother pigs, or sows. This is meant to immunize the sows against a virus, porcine epidemic diarrhea, or P.E.D., that has ravaged the hog industry, killing millions of piglets.

Tom Burkgren, the executive director of the American Association of Swine Veterinarians, said that feeding the piglet intestines to sows is legal and safe but that hog farmers are increasingly finding that it’s more effective simply to use diarrhea from an infected animal to expose sows to P.E.D.

That’s a reference to mad cow disease, which was spread by feeding ground-up cows to other cows. Likewise, giant poultry farms feed “spent hen meal,” consisting of ground-up old chickens, to egg-laying hens.

Whether or not there are public health risks to feeding pig parts to pigs, there are larger issues about the way we raise our food. Nine out of 10 sows in America are kept in gestation crates, according to the National Pork Producers Council. These are tiny stalls that are barely bigger than the pigs, who don’t even have enough room to turn around.

They live out their adult lives without exercise or meaningful social interaction; it’s like a life sentence of solitary confinement in a coffin, punctuated by artificial insemination and birth. No wonder the animals’ muscles atrophy and they show signs of aggression and stress.

Willis says of the factory farms: “They have to feed the animals laxatives because they don’t get enough exercise to defecate. The pigs get sores, the equivalent of bedsores from concrete. They get joint problems.”

My family raised pigs on the Oregon farm where I grew up. Our hogs were as smart as dogs and had personalities just as distinct. I also learned that it’s a misconception to think of pigs as filthy. On the contrary, when they have space, they are quite tidy and don’t defecate near where they sleep. They cover themselves in mud partly to avoid sunburn.

Industrial farming is justly proud of its efficiency. But to curb disease in crowded conditions, it routinely feeds antibiotics to animals, spreading antibiotic-resistant microbes that then infect humans. Confinement operations also produce vast amounts of manure that pollute water sources. So while factory farms produce cheap pork, they impose external costs such as pollution and disease that the public pays for.

While forcing hogs to be solitary and immobile in gestation crates for their entire adult lives is soul-crushing, popular disgust is leading to a revolution in industrial farming practices. Whole Foods and Chipotle and Burger King were among the first companies to avoid pigs raised in gestation crates, and, in the last few years, McDonalds, Safeway, Costco, Oscar Mayer and dozens of other companies have announced similar moves, often after a transition. It doesn’t seem as though costs will rise significantly.

Carl Icahn, the investor, warned Tyson Foods that it had to drop gestation crates if it wanted to find buyers for its pork. Tyson got the message: Just last month, it wrote to all its suppliers and told them to treat pigs more humanely and to give them space to turn around. Smithfield Foods, which is the world’s largest pork producer and was acquired last year by a Chinese company, last month reaffirmed its commitment to transition away from gestation crates.

So the tide is turning because consumers are making their preferences known. Today perhaps the larger scandal is the push by agribusiness for “ag-gag” laws that ban undercover videos like the Humane Society’s. The aim is to hide abuses of animal welfare by denying the public access to information about how livestock are raised.

“We’re deeply disassociated from so much of the animal cruelty in our society,” noted Wayne Pacelle, the president of the Humane Society of the United States. “This kind of conduct would not be tolerated if it were visible.”