Dash camera battery upgrade

Hi, me and my colleagues have dash camera's and while they are great when the vehicle is running, we would like to record for a few minutes after the engine has turned off.

Currently our dash cameras are setup like most generic cameras, they auto turn on and off whenever they receive 5v USB power.

i.e. car accessories 12v > 5v adapter > dash camera (500mA max)

I tried adding a USB battery pack with pass through but this caused its own issues: - heat (70degC +) - constantly flat USB battery pack

My proposal is to add an arduino into the loop to power the camera for X minutes and then turn off, saving the USB battery.

Proposal: if Vin, turn on Vout if Vin = off, wait X minutes, turn off Vout

I thought this would have come up before but I have been unable to find any diagrams or sketches and I dont want to reinvent the wheel (and miss a needed resistor or capacitor somewhere).

Can someone point me in the right direction. Thanks.