Thanks for the info, I was thinking the same thing, it's gotta be caps.
Geez these iMacs seem to have a whole bunch of problems. They don't seem to be very reliable.
That iMac is more than ten years old. Capacitors, the components that are probably failing right now in your power supply, have a life expectancy and don't work forever. That's why even the most reliable machines Apple has ever released will undoubtedly fail soon or late. Now, after ~25 years, the capacitors inside the first Macintoshes (128K, 512K/Ke, Plus, SE...etc) are starting to fail (all of them) nowadays. If you buy one of those classic AIOs today, you'll get the impression that they weren't very reliable. But actually they were. Components in all computers fail. Capacitors are usually the first ones.
Apple usually uses high-quality components, even in capacitors (that's something people tend to forget when they look at the specs). PCs usually don't, and even when the power supplies inside them are fan-cooled and should have a better life expectancy because components are cooled, they don't.
Back to the topic, you can take the power supply out of the iMac, insert a clip connecting GND (ground) and PowerON to make a bridge and then connect the power supply to the AC plug. It isn't dangerous if you do it well, just don't touch anything while connected to AC. That might help you to found the dead capacitor or the failing component, although if you have the necessary skills (it's easy) I'd recommend to recap the whole power supply. The life expectancy of the capacitors is rated in hours, so if one capacitor has failed, probably the nearby similar one's are going to fail soon too, even if they don't look damaged.
It's important to do it, because if the power supply fails, it may fry all the other components in the line. For example, if suddenly the PSU seeds just 3 or 4 volts in the 5V line (or any other), more things will fail. The same if the 12V line suddenly becomes a 18V line. I wouldn't take the risk. Actually, it could have started. Did you know why the CD/DVD drive died? It could be because of the power supply giving a wrong input. Same for the fly back.