Timelapse Timestamp - Current situation?

What is the problem?

Want to add timestamps to timelapse videos.

What did you already try to solve it?

Researched....

I've read through a thread on this topic from 2019 and wanted to check on what is going on now and try to sort through what I did find in that thread.

The short version is that I'd like to be able to print timestamps on timelapse videos. I'm starting to do longer prints, including some of my own design, and timestamps would help for troubleshooting.

After reading through the linked thread, from what I can put together:

  • MotionEye will let me put timestamps on. I Googled "MotionEye" and found several hits for what look like different products or projects, but the one I found that I think was more relevant was for an OS. I'm using OctoPi and would like to just keep it all on one Pi. (Especially since Pis are so hard to get now!) If I'm wrong, and MotionEye is something I can use on a Pi 3 or 4 with OctoPi on it, I'd be interested in hearing more about that.

  • OctoLapse apparently can do this, but it looks quite involved. I don't want to have to change slicers or to do something that might compromise print quality. I like the idea behind what OctoLapse does, but for now I'm doing still images every 10 seconds and, as I mentioned, this is for troubleshooting, so I'd rather have the more frequent screenshots than one per level or between each level or something like that.

Is there something else now, 3 years after that previous thread, to use to put a timestamp on the timelapse videos? Even a way to add them to the main video stream would do, if it were possible to add a processing step to what mjpg_streamer is doing. (One issue with this is I've tested adding options to mjpg_streamer and it didn't work - but I'm also doing multiple printers and webcams and I've brought this up in the multi-printer forum and would probably go back there if it's a matter of more command line options.)

I wrote a guide on how to do this with existing OctoPrint functionality and no plugins:

It's maybe a little involved since you do still have to install ImageMagik, but I think it's still fairly simple compared to additional plugins or scripts

Thank you!

Just glanced at it. Of course installing anything with apt is a breeze, so that's not a big deal. I'm used to doing admin for Linux systems.

From reading the start, it looks like the timeplapse feature basically captures still images and keeps them until the print is done and the rendering is assembling them in a video and you basically just grab them after each one is saved and use ImageMagic to timestamp them. Nice way to fit in with what's already set up and add a new feature!

I'm finding two issues with this. I did all this and didn't get timestamps. I went in and fount ~/.octoprint/timelapse and found all the stills were in ~/.octoprint/timelapse/tmp. I copied some into a different directory so I could experiment. I also used scp to copy one normal and one backup image (ending in '~') to my desktop. I checked both and neither had a timestamp on it.

So I ran the same command I entered into the event in OctoPrint. It created a backup file (with the '~') in the same directory and gave me this error:

mogrify-im6.q16: unable to read font `helvetica' @ error/annotate.c/RenderFreetype/13381.

Apparently the Helvetica font is not included by default now (if it ever was). To save me a fair amount of searching, it'd help if anyone could tell me where to find the fonts that are included or what package Helvetica is in. (I did search with apt, but found multiple packages. I tried one and it didn't help.)

The other issue I brought up in my listing of what I did and what happened. The backup files, with the tilde on the end, are not removed when the timelapse is done. I found the backup versions of all the files from the first timelapse I tried with this enabled. No normal image files, just the ones with the tilde on the end. So once the filename is modified, it's not deleted during rendering. I don't know if anything comes along at some point and deletes all the files in ~/.octoprint/timelapse/tmp or not. I know I did a reboot and that didn't delete those files.

What specific command did you run? The examples listed in the guide doesn't specify font and without specifying a font ImageMagick should be choosing a sane default on any system.

If you specially asked for Helvetica, then of course you will need to make sure it is available.

For what it's worth, Helvetica should in the gsfonts package in Debian based distributions.

I've never gotten stale/leftover ~ backup files from ImageMagick before, they may be getting left around from the errors. You can delete the existing ones manually.
A quick google search suggests that if these persist that it's a permissions issue that keeps ImageMagick from deleting them, but that's unlikely unless you're running things as multiple users.

Here's the command line (as a block quote - tried unfomatted text and it's a long sideways scroll):

[22-11-05 2:43:12 pi@erebor ~] $ mogrify -pointsize 36 -fill white -gravity southwest -annotate 0 '{__filename}' -pointsize 36 -fill white -gravity southeast -annotate 0 '{__now}' -pointsize 24 -fill white -gravity northeast -annotate 0 'Z = {__currentZ}mm' tstest/DrawerKnobs-2-MinimalSupport_0.15mm_PLA_MK3S_4h32m_20221105014515-101.jpg
mogrify-im6.q16: unable to read font `helvetica' @ error/annotate.c/RenderFreetype/1338.

(I realize that without it being done in OctoPrint, the placeholders won't be replaced. I just left them in there because it was easier to do that.)

While I've modified this Pi by adding a 2nd instance of OctoPrint, I haven't done anything that should mess with fonts or defaults like that.

I did get it to work. I copied a number of test files over to another directory and renamed them for shorter names to make it easier to deal with shorter file names. I had previously used:

sudo apt install fonts-freefont-ttf

and that installed a set of fonts in /usr/share/fonts. I checked the font names in there and used one of them and used this command:

mogrify -font FreeSans -pointsize 36 -fill white -gravity southwest -annotate 0 '{__filename}' -pointsize 36 -fill white -gravity northwest -annotate 0 '{__now}' -pointsize 24 -fill white -gravity northeast -annotate 0 'Z = {__currentZ}mm' Test100.jpg

Yes, once I was sure what was going on, I deleted all the backup files. I found that when mogrify works, there are no backup files, so I think that just relegates this issue as something to be aware of if it's not working. Apparently mogrify creates the backup file when it starts, then, if it completes the command, it deletes the backup of the original, otherwise it leaves it.

So I have it working for me now. The base issue is that, for some reason, it was not able to access a font it should find. Also, I don't know if fonts are stored in various places, but after I installed the font package I mentioned, when I checked /usr/share/fonts, it looked to me like the only fonts there were from the package I specified. I can't be sure about that, though.

I think it'd be interesting to hear if others have had this issue. I don't know why I did, but I think it could be prevented for others if they install a font package like I did and add a font name from that package to the command.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.