Both are correct. , both the plain infinitive (shout) and the present participle (shouting) are correct. If the verb of perception is in the passive voice, to is needed before the infinitive: He was heard to shout.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.