Have you inspected and ohm the Crank Sensor? My Crankshaft sensor went out on my 97 Camry resulting similar issues. Also inspect the Crankshaft sprocket. My had two damaged teeth on a previous 98 Camry I had resulting car shutting down after 5 seconds of running.