I am calling ffmpeg from a custom tool to concatenate video files while overlaying a timestamp in the output. The output video needs to have a timestamp starting at an arbitrary time. The format must be a 12-hour clock with seconds and meridiem, e.g. 10:34:59 AM or 6:13:09 PM. Here's the full command I'm using right now:
ffmpeg\bin\ffmpeg.exe -y -i "concat:input.mod" -ss 00:00:00 -t 00:02:17
-an -vcodec libx264 -profile:v baseline -level 13 -b:v 2000k -vf
"drawtext=fontcolor=white:fontsize=16:fontfile="/Windows/Fonts/arial.ttf":
box=1:boxcolor=black@0.3:x=(w-text_w-10):y=(h-text_h-5):
timecode='02\:36\:17\;00':rate=30000/1001" output.mp4
This outputs a 2 minute, 17 second duration video beginning at the start of the input file. The output video has a timecode in the bottom-right corner beginning at the time 02:36:17 and ending at 02:38:34. What I want is exactly this, but instead of printing "02:36:17;00" on frame 0 and counting up from there, it should print "2:36:17 AM" on frame 0 and count up from there.
I have tried using the localtime
function to output formatted time, but the time value it uses is the time that the drawtext
filter is called. It doesn't take a parameter for an arbitrary time.
I have also looked at the pts
function, which seems to allow an arbitrary offset but only supports two formatting options, neither of which is the clock format I need.
What is the proper way to add a timestamp with an arbitrary starting time and format using ffmpeg?