We used to raise hogs on our family farm here, and to be honest I didn’t much like them. Defenders of farm animals sometimes compare pigs to dogs, but our hogs didn’t display any canine-style affection and instead were grouchy, whiny, strong-willed and prone to wander.

Once when I was about 15, I had to traipse through the forest for more than two miles to track three of them down, and herding them back was a nightmare. By the time we got home, those pigs must have concluded that humans were a particularly ill-tempered and unaffectionate species.

Still, our pigs were indisputably very smart with distinctive personalities, and sows made terrific moms (helicopter moms, too, keeping a close eye on wayward piglets). In short, I wouldn’t compare pigs to golden retrievers — they’re much more like people.

We no longer raise pigs on our farm, nor do most other small family farms. Now they are nearly all on huge factory farms and treated with what seems to me particular cruelty — as reflected in secret videos taken by undercover investigators and just released by two animal rights groups.

Animal Outlook, a nonprofit based in Washington, D.C., and Los Angeles, sent an investigator to work for four months at Holden Farms in Utica, Minn. The investigator filmed piglets being castrated by hand without any anesthesia — workers made incisions in the scrota and then pulled the testicles from the body as the piglets screamed in pain.

“They are absolutely terrified,” the investigator who filmed the scene said. He doesn’t want his name published because he may continue with undercover work.

The video also shows employees mixing intestines of dead piglets to feed to pregnant sows, turning them into cannibals, on the theory that this would boost their immune systems.

Sick or injured piglets on the farm were euthanized by carbon dioxide in a sealed box, he said, but this is sometimes ineffective, and the video shows some pigs surviving the ordeal and still moving. The investigator believed that a supervisor was skimping on carbon dioxide to save money.

The video was filmed three years ago, and Animal Outlook said it sought unsuccessfully to work with local law enforcement to win a prosecution on animal cruelty charges. The organization said that since the statute of limitations has now expired, it is releasing the video.

Reached for comment, Holden Farms did not address specific questions about castration or euthanizing of piglets but noted that the video was several years old and said it was conducting an internal investigation and would take “corrective actions where necessary.”

“We recognize the concerns over what is portrayed in the video but believe many of the images shared have been intentionally taken out of context and do not represent how we normally care for animals,” Holden Farms told me.

“Animal care is a top priority for Holden Farms, and we continually challenge ourselves to utilize new technologies to improve on-farm practices involving the proper care of animals,” the company added.

So you decide. Here’s a video from Animal Outlook showing what happens inside a barn — please be forewarned that it is graphic and hard to watch:

The other undercover investigation was by Mercy for Animals, a Los Angeles-based nonprofit working to end factory farming. Its investigator, who also asked not to be named, worked in a hog barn in Nebraska operated by a company called Buffalo Plains Genetics. It did not respond to requests for comment.

The Mercy for Animals footage does not show abuses as striking as those in the other video. But it reinforces my view that today’s mass production of pork is intrinsically inhumane.

In both hog operations, the pregnant sows are confined in narrow pens called gestation crates. These vary but are typically a bit shorter and narrower than a human coffin, so that a sow can barely move and certainly can’t turn around.

“A gestation crate is like living in an airline seat,” Temple Grandin, a leading livestock scientist, told me.

When the sows are ready to give birth, they are transferred to farrowing crates, which are similar but have areas to the side for piglets. Then after a few weeks, the sow is taken away to be artificially inseminated and returns to a gestation crate, and this is repeated until she is no longer productive. And then she is killed.

Here’s the video from Mercy for Animals:

Two points can be made in defense of the system. First, it is stunningly good at producing cheap pork, saving money for low-income families. In 1950, pork chops were selling for almost $10 a pound in today’s money; now they are less than half that. These big farms are efficient in a way our little family farm never could be.

Second, the pigs have ready access to food and water, they do not regularly suffer parasites, and the temperature is controlled. Our pigs were more likely to suffer hot or cold, or to get sunburned, than factory-farmed hogs.

Yet factory farms impose costs that aren’t included in the price of pork chops. A single farm with 10,000 adult hogs, for example, might produce as much feces as a city of 100,000 people, yet lacks a sewage treatment plant to keep streams from becoming contaminated.

As for the hogs themselves, although they are fed and watered, can they truly live? Locked up, unable to move around, they chew the metal bars in apparent frustration and bite one another’s tails — something even the grouchiest of our pigs never did. So factory farms often preemptively remove pigs’ tails, usually without anesthetic.

If a teenage boy were to cut off the tails of animals and yank off their testicles, he might be arrested and castigated for his cruelty; if he grows up and becomes C.E.O. of a company that does this on a mass scale, he will get rich and be praised for his business acumen.

While the videos show low-paid workers mistreating animals — and callously throwing pig testicles at one another — they too are cogs in the system.

“We have upper management breathing down everybody’s neck, so employees are stressed out,” the investigator at Holden Farms said. “The stressed-out workers tend to take out their frustration on animals.”

The agribusiness industry is trying to get Congress to pass legislation, called the Ending Agricultural Trade Suppression, or EATS, Act, which would undermine local animal welfare laws. This would be a huge step backward: I think it should be renamed the Animal Abuse Act.

I don’t know precisely how to negotiate the trade-offs between profitability and compassion. What if pigs were given twice the space and treated with more humanity? How much should we be willing to raise food costs to improve animal well-being? I struggle with questions like these.

What I am confident of is that right now we’re on the wrong side of history and that future generations will look back at videos like these and be baffled that nice people like us could blindly tolerate such systematized cruelty toward intelligent if cantankerous fellow mammals not so different from us.