Android IP Webcam and phone overheating

This is a question for those of you that are using Android IP Webcam on an old cell phone. How do you keep the phone battery from overheating? I have the display turned off but the phone still overheats and the phone shuts down. Everything with the integration works just fine - just not my old pixel 4a phone.

Your battery is probably dead and can not be fully charged.
Your phone will try to charge the battery to full though and that is what cause the heating of the battery.

It does have a battery problem - it doesn’t hold a charge for long.

I took off the case right after I posted this and so far (fingers crossed) the battery temperature has been fine and the webcam is still running.

Thanks for taking the time to reply.