I don't think there's any substitute for (a) being polite ("Yes, sir. No, sir.") and (b) being aware of the context. Obviously you should never consent to a search or even give the impression that you're consenting. But literally not talking to the police is not really possible, so there's no avoiding keeping your wits about you so you can act in the most appropriate way possible.
Pulling out your camera is a pretty ballsy move that could escalate things, but I wasn't there so can't judge. But if there were witnesses watching such as other passengers or, especially, a conductor, I wouldn't risk it. I'd just ask for the witnesses' contact information afterward. An irate cop could always snatch your phone away; it's much harder to intimidate a witness, and anyone inclined to do that probably wouldn't think twice about taking your phone or doing something worse later, anyhow. Ultimately you're pretty much helpless, so you have to optimize for the [more likely case] of the cops being mostly honest. They're unfortunately trained to intimidate (we've militarized our civilian police forces), so just because they're acting like assholes doesn't mean they're actually assholes.
Am I missing something?
I don’t know what the right answer is, it seems like a tough call. I’m skeptical of people who confidently say “consenting is never the right answer”.
https://www.youtube.com/watch?v=d-7o9xYp7eE
Mandatory viewing IMHO.
Even if they don't steal or plant anything, it's a huge invasion of privacy and, if you have any delicate items, a risk that they'll be damaged.