2

Using ffmpeg, I would like to overlay the current local timestamp with milliseconds onto a video using ffmpeg in a YYYY-MM-DD HH:MM:SS.mmm format. I've seen a similar question asked, but did not see an answer to displaying millisecond portion.

Using text=%{localtime} simply displays YYYY-MM-DD HH:MM:SS without milliseconds. If you try to use common millisecond specifiers to display the milliseconds portion it does not work as in text=%{localtime\\:%Y %m %d %H %M %S %s} or text=%{localtime\\:%Y %m %d %H %M %S %f}.

If you use text=%{pts\\:hms} it does display milliseconds, but it's not referenced to current local time. You could add an offset in total seconds since midnight to bring you get you close to the local time as in text=%{pts\\:hms\\:61200} to get you to 5pm, but that is a snapshot of when the command was called, not the actual current local time the video frame was captured in milliseconds.

UPDATE:

I just found this article: https://github.com/InSoundz/ffmpeg-strftime-milliseconds
It looks like someone had added millisecond resolution to the strftime() function that ffmpeg uses.

My only issue is I do not know how to re-build the Windows release *.exe using this source code. Can anyone assist with this? Once that is re-built into a Windows executable, then I should be able to add millisecond resolution using a %u formatter as in: %Y-%m-%d_%H-%M-%S.%%03u to get the example of 2017-05-28_12-26-33.599 timestamp added to the recorded video. Could anyone please assist me with this Windows *.exe re-build using this modified library?

Any help on this would be greatly appreciated!

1

1 Answer 1

1

From the drawtext documentation:

localtime
The time at which the filter is running, expressed in the local time zone. It can accept an argument: a strftime() format string.

However, strftime does not have a function to display milliseconds. See man strftime.

You used %s which is the, "number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC)". Not what you want. I'm not sure where you found %f, but it's not valid for strftime.

4
  • Thanks for the info - agreed - hopefully someone has an idea of how to gain the localtime with millisecond resolution to add to the recoded video!
    – svojoe
    Nov 19, 2020 at 15:57
  • @svojoe I know it wasn't the answer you were looking for but unfortunately I do not have an alternative solution.
    – llogan
    Nov 19, 2020 at 18:53
  • Thanks for the suggestion - if you read my 'UPDATE' within my original question - it looks like someone has already created a updated strftime() function with milliseconds added for use with ffmpeg - I just need assistance with re-building ffmpeg for a windows *.exe release using the updated function - I have no experience with this... The current Windows *.exe autobuilds for download do not include this updated strftime() function.
    – svojoe
    Nov 19, 2020 at 20:08
  • @svojoe That's 4 years old so probably won't apply to the current codebase and it appears to have been implemented just for the segment muxer output file name. I don't use Windows so I won't be much help there.
    – llogan
    Nov 19, 2020 at 20:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .