My car dash cam is a peculiar one bought off amazon.com forgot its name. Something like petzio and an old model. Does not have wifi nor does it unmount the microsd card. Hence taking it out and inserting into a linux laptop is the only way to recover the recordings. Even then the last file if not stopped recording before ignition off will be corrupt with no proper header. Also the rear cam records only mirror image with time stamp embedded and at resolution 640×480. I have my own shell script to convert the front and back files and combine them with rear camera view flipped and cropped at 640×320 and scaled down to embed into the front camera combined file.
Recently I had few requirements to keep the rear cam feed as a flipped and cropped separate file with correct timestamp embedded. Had thought about this for long and found a solution using a combination of php, imagemagic and ffmpeg to generate a time stamp embedded sequence. Will show off the screenshots one by one and explain.
The above is a screenshot of the raw file being played and one can see that it seems my car as well as the biker is on the wrong side of the road, because this video is a mirror image and needs flipping. But as the timestamp is embedded, flipping will render the timestamp unusable. So an ffmpeg command is run as below.
ffmpeg -i input.mov -filter:v "crop=640:320:0:0,hflip" bc.mp4
This one image is the flipped note hflip in the ffmpeg video filter and the crop also to cut away the timestamp.
The above is a screenshot from vscode editor with the php code which I used to generate the timestamps but actually for another video as the start time is a bit skewed and the final echo contains the imagemagick command which is piped to /bin/bash to generate 25 frames for each second and finally ffmpeg is used to create the combined video from the sequence of zero padded files with following command
ffmpeg -y -i tx_%05d.png -hide_banner -c:v libx264 -r 25 -pix_fmt yuv420p timex.mp4
Original cropped and flipped file is now overlayed with this time stamp video again with ff-mpeg. The command which worked for me is as follows.
ffmpeg -i bc.mp4 -i timex.mp4 -filter_complex "[1:v]scale=in_w:-2[over];[0:v][over]overlay=0:270" -c:v libx264 "combined.mp4"
Screen shot from the final output more or less at the same point in the video