A Texas sheriff's deputy is lucky to be alive after his patrol car was hit by a train this week.

Several passersby caught the dramatic crash on video.

In those videos, two Midland County sheriff's deputies are seen waiting for a train to pass at a marked railroad crossing. After the last car makes it past the intersection, one of the deputies drives around the crossing arms and is slammed by a second oncoming train that he apparently didn't see coming.

The force of the collision pushed the patrol car several hundred feet and flipped it on its side.

Midland County Sheriff Gary Painter told the Midland Reporter-Telegram that the deputy was "banged up" but still was "walking and talking" and otherwise OK.

The deputies were reportedly en route to a call about a child in distress when the passing train delayed them.

The Reporter-Telegram says the Texas Department of Public Safety, a state law enforcement agency, is investigating the crash.