-- Leo's gemini proxy
-- Connecting to gemini.splashgel.net:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini
Some action cams make good dash cams, but don’t timestamp the videos. They save the individual video files with a creation time corresponding to when the video starts, so you can add your own timestamp to the video. Not ideal, and requires a re-encode, but it’s something.
There are some answers out there on how to do this, but mostly along the lines of “copy this long command line and hope for the best”. I prefer to know at least a little bit about what I’m doing. If you just want a command line to copy and paste then scroll to the end.
The idea is to use the ffmpeg drawtext filter:
This also supports text expansion, which is mainly to do with timestamps and frame numbers; the `pts` expansion is perfect for our needs, as it adds the timestamp of the frame to an offset, and formats it as the local time. The final argument, 24HH, gets it to use a 24-hour clock, but you can leave that out.
%{pts\:localtime\:??????\:24HH}
The question marks stand for the offset. If you put it as zero it starts at 1/1/1970, so we need to find out the creation time (or ‘birth’ time) of our file as a seconds-since-epoch (the ffmpeg manual doesn’t actually say that the offset is in seconds, but it is). This is different on different systems...
Start with this:
stat -c %W file
which gets you the birth time. If it fails try %Z for the last status change or %Y for the last modification time. You can also try
/bin/ls -l --time-style=+%s file
For the birth time:
stat -f %UB file
Or if the birth time is undefined, %Um is for the modification time.
There are a few more options to do with formatting the text that are documented in the filter manual linked above. It all goes together something like this (using the 12-hour clock this time):
ffmpeg -i input.mp4 \ -vf drawtext="fontsize=45:fontcolor=white:bordercolor=black:borderw=2:text='%{pts\:localtime\:1612004101}':x=(w-text_w-4):y=(h-text_h-4)" \ -c:a copy -c:v libx265 output.mp4
If it’s a fancy high-res source video it might take a while though!
-- Response ended
-- Page fetched on Sun May 19 00:44:01 2024