Jump to content

Making Time Lapse Videos with the Ultimaker 3


unlimitedbacon

Recommended Posts

Posted (edited) · Making Time Lapse Videos with the Ultimaker 3

Hi Everyone. I wanted to share a little python script I wrote for making time lapse videos with the onboard camera on the Ultimaker 3. Here is an example from a rather messy print I just did.

EntireGlassAlaskanmalamute.gif

Get it on GitHub.

There's probably a lot of generic webcam tools for doing this already, but this one is nice because it doesn't start taking pictures until the printer begins printing, and it stops once the print is completed.

The script requires Python 3 and FFmpeg.

 

Usage

 

$ ./timelapse.py HOST DELAY OUTFILE

 

HOST is the IP address of your Ultimaker 3. You can find this through the menu by going to System > Network > Connection Status.

DELAY is the time between snapshots in seconds. You'll probably want to figure this out based on how long your print will take and how long you want the video to be. For example, if I want a 10 second video at 30 fps, that will be 300 frames. If the print will take five hours, then 5 hours / 300 frames = 60 seconds between frames.

OUTFILE is the name of the video file you want to make. It will be encoded using H.264 at 30 FPS. You can choose any container format you want, but I recommend either .mkv or .mp4.

Edited by Guest
  • Like 5
Link to post
Share on other sites

Posted · Making Time Lapse Videos with the Ultimaker 3

Thanks, @tinkergnome!

Yes, the problem is line 58 in um3api.py. For some reason os.getlogin() does not work on my Linux systems, so I had to change it to use pwd.

 

>>> os.getlogin()Traceback (most recent call last): File "", line 1, in FileNotFoundError: [Errno 2] No such file or directory

 

Do you know of a more platform agnostic method?

  • Link to post
    Share on other sites

    Posted · Making Time Lapse Videos with the Ultimaker 3

    Do you know of a more platform agnostic method?

     

    Sorry, I'm not familiar with Python. But there's no authentication necessary to read the status and the snapshots. How about completely removing of "__checkAuth" and "loadAuth"?

  • Link to post
    Share on other sites

    Posted · Making Time Lapse Videos with the Ultimaker 3

    I need some help.. i am new to this.

    I installed python and downloaded the script and put it in the lib directory of python.

    I downloaded FFmpeg but it isn't an install only an extract. So were do i put this.

    if i run the command line i get the line File "" , line 1

    could somebody please make a bit more step by step explanation for the ones that are not familiar with this.

    thank you

  • Link to post
    Share on other sites

    Posted · Making Time Lapse Videos with the Ultimaker 3

    Hi UltimateBacon,

    it's sound exactly as what I need but like Arno before me I have no idea were to start. Can you make it a for dummies pls :-) What to do with the ffmpeg file and how to use python to execute this script...

    would be much appreciated

  • Link to post
    Share on other sites

    Posted · Making Time Lapse Videos with the Ultimaker 3

    Wish ultimaker would include this function on their next firmwere update.

    Its pretty standard now on other machines

    • Like 1
    Link to post
    Share on other sites

    Posted · Making Time Lapse Videos with the Ultimaker 3

    Hey unlimitedbacon,

     

    I tried your timelapse script but probably I am forgetting something...

     

    First of all if I open the script with th editor "IDLE". But this is only possible in the folder I downloaded it to. I tried to copy the files to the Cura folder in order for Python to find the "request"-module over there but there IDLE would not even open the file (don´t know why). Anyhow, I Installed Python and got the ffmpec codec like it was said. Then I tried to execute the ffmpeg.exe but it opened ony a tiny window for a 10*10^-4th of a second.. So there was no visible result!

    Then I installed Python which went ok. I then downloaded the script. Trying to start it from there would bring me the same result as trying to start ffmpg.exe

    After looking at the IDLE-Programm I found out that I could also run the script from there but I would give me the following message:"no module named ´requests´". (I added a foto for you to see what the programm would say.)

    I even tried to start it using your prompt from the Total Commander and CMD, but that had the same effect like trying to start the ffmpg-File. I tried something like

    "timelapse.py 192.168.1.3 10 Daniel.mp4" (more ore less what you asked for in the beginning of the threat...

     

    Anyhow. Probably I am missing out something really simple or probably I have to modify the script... I am out of ideas maybe to can help me in some way..

     

    Greetings

     

     

    Daniel

    Image4.jpg

  • Link to post
    Share on other sites

    Posted · Making Time Lapse Videos with the Ultimaker 3
    On 15.1.2018 at 10:31 PM, Harry Plotter said:

    Hey unlimitedbacon,

     

    I tried your timelapse script but probably I am forgetting something...

     

    First of all if I open the script with th editor "IDLE". But this is only possible in the folder I downloaded it to. I tried to copy the files to the Cura folder in order for Python to find the "request"-module over there but there IDLE would not even open the file (don´t know why). Anyhow, I Installed Python and got the ffmpec codec like it was said. Then I tried to execute the ffmpeg.exe but it opened ony a tiny window for a 10*10^-4th of a second.. So there was no visible result!

    Then I installed Python which went ok. I then downloaded the script. Trying to start it from there would bring me the same result as trying to start ffmpg.exe

    After looking at the IDLE-Programm I found out that I could also run the script from there but I would give me the following message:"no module named ´requests´". (I added a foto for you to see what the programm would say.)

    I even tried to start it using your prompt from the Total Commander and CMD, but that had the same effect like trying to start the ffmpg-File. I tried something like

    "timelapse.py 192.168.1.3 10 Daniel.mp4" (more ore less what you asked for in the beginning of the threat...

     

    Anyhow. Probably I am missing out something really simple or probably I have to modify the script... I am out of ideas maybe to can help me in some way..

     

    Greetings

     

     

    Daniel

    Hey to all who read this... Problem is solved! I try to post how as probably som others want to know how and what the problem was about...

     

    Greetings Daniel

    On 15.1.2018 at 10:31 PM, Harry Plotter said:

    Image4.jpg

     

  • Link to post
    Share on other sites

    Posted (edited) · Making Time Lapse Videos with the Ultimaker 3

    Hi

     

    I'm new to this too but this is how I managed to get it running. I installed Python 3.6.4 then I downloaded the time-lapse project files then opened a Terminal session on my iMac. Once the window opens, change to your downloads folder using cd Downloads then to the folder the zip file extracts to, um3timelapse-master using cd um3timelapse-master. You are now in  the folder you need to work in.If you forget the name, just type ls as a terminal command to list the files in that folder

     

    From here, you can run the python scripts directly but you MUST remember that OS-X comes with Python 2.7 and if you just try and run it in this, it won't work. You have to clearly define you want to use python 3.6 in your commands, thus:

     

    To install the requests module, type python3.6 -m pip install requests

     

    You then type python3.6 um3api.py and allow that to run

     

    Next, type python3.6 timelapse.py 10.100.192.122 20 sample.mp4

     

    In the above example, 10.100.192.122 is the IP address of your UM3 Printer. 20 is the delay between images in seconds then 'sample.mp4' is the name of the file saved when the print is finished

     

    The program will wait for your UM3 to start printing then you will see it writing the capture number in the terminal window. I did find though that it kept losing contact with the printer but this is probably the way I'm connecting over a busy network.

     

    Hope this helps. Please let me know :)

    Edited by PeteG
    • Like 1
    Link to post
    Share on other sites

    Posted · Making Time Lapse Videos with the Ultimaker 3

    So to all out there who download Python and ffmpeg and still have problems:

     

    1. Make sure that you have downloaded the right version of Python (there are different versions for 32-bit and 64-bit Systems available).

    2. After the installation don´t confuse the syntax for starting programs in Unix-based OS´s with those of WIndows... there are huge differences in installing and running the applications.

    3. First put the folder of ffmpeg (not zipped) in a path where it is easy to find e.g "c:\ffmpeg\"

    4. Then tell the PC how to find it there... there is a link which helped me to do so: https://de.wikihow.com/FFmpeg-unter-Windows-installieren it is written in German, but you will be able to find out by the fotos attacht to the explanations... in fact I did not have to read them either.

    5. The most important information (at least that was for me): If you start python you will not be able to run the script in the shell itself. I mean you can tell the interpreter IDLE to open, or run it but eventually it won´t work because:

    A) For me the package "requests" was not installed, so you have to install this first... as long as you haven´t done that Python will stop there giving you out a line where it sais something like line 4 "request" is not a known package...

    B) If you have managed to get Python to know "requests" then you will still not be able to run it over IDLE because it will start the script without telling it the 3 magic informations (HOST, DELAY and name"OUTPUTFILE".mp4).

    6. So in order to do so you have to start the script with the CMD-Program (Command Program) of Windows. Open this program and go exactly (where no one els has ever boldly dared to go before) to the folder of the timelapse.py script. For me that was "C:\Users\Administrator\Desktop\."

    7. I order to go there please review the syntax of the CMD-Program --> "cd", "md", "rd", "dir" (you´ll manage all with "CD" and "DIR")

    8. If you are where your script is. then use the following parameters in order to start the timelapse-process: python timelapse.py Host (for me that was 192.168.1.3 Delay (for me i tried out 10 first then I can try and go higher to save time or lower to go more detail) and Output file (I tried Danni.mp4 to keep things simple the first time).

    9. If it does not find Python in order to start the script you might have to tell the computer where to find it. For this reason please use this link: https://www.pythoncentral.io/add-python-to-path-python-is-not-recognized-as-an-internal-or-external-command/ but for me this was OK, and the PC did find it after the installation directly...

    9. Then it should work fine and wait for you to start the printing process.

    10. Make sure you have Cura loaded and settings ready for printing as I don´t know if it will work elsewise. I suppose not as Cura establishes the connection between the printer and the program...

     

    Anyhow these steps worked for me and my first print is timelapesd just now. I am quite happy to have found out by myself and so can you.

     

    So happy timelapsing and pls do post some timelapses once you have suceeded.

     

    Happy printing

     

     

    Daniel

     

    timelapse.py HOST DELAY OUTFILE

    Command promt.jpg

    • Like 2
    Link to post
    Share on other sites

    Posted · Making Time Lapse Videos with the Ultimaker 3

    Finally did it!. Video is ready... FANTASTIC!

     

    Wasn´t a clean print sry but my first with 0,1 and probably I have to adapt some ventilation with PVA as for 0,15 there is no stringing...

     

    Unfortunately I can not upload .mp4 files so I leave you with some fotos from the compressed single fotos that timelapsy.py took... 1 at the start 1 middle and 1 last foto. Then I took a real foto from the finished print...

     

    Hope you enjoy.

     

    Greetings

     

    Daniel

     

     

    03097.jpg

    02974.jpg

    01731.jpg

    00526.jpg

    Final print.jpg

  • Link to post
    Share on other sites

    Posted · Making Time Lapse Videos with the Ultimaker 3

    You could upload it to dropbox or one of hundreds of other free services and then post a link to the video.

     

  • Link to post
    Share on other sites

    Posted · Making Time Lapse Videos with the Ultimaker 3
    On 10/17/2017 at 10:31 AM, Karam said:

    Wish ultimaker would include this function on their next firmwere update.

    Its pretty standard now on other machines

    It would be an interesting feature, but

    1. We don't want to store videos in the printer (conflicting space requirements, management of files etc)
    2. It will also time to process the images and create the video, in which case this is a chance of the actual printing to be slower and thus possible artifacts. I'm sure nobody wants that.

    Hence the idea of just capturing images and put them together as a movie outside the printer is more beneficial.

    • Like 1
    Link to post
    Share on other sites

    Posted · Making Time Lapse Videos with the Ultimaker 3

    @PeteG and @Harry Plotter, Thanks for helping the newbies with using Python and for figuring out how to get everything set up on Windows. Sorry I could not respond earlier. I have not tested this on a Windows machine myself.

     

    I'd just like to point out that there is no need to have Cura connected, running, or even installed on your computer in order for this script to work. It is completely independent.

     

    @Marco_TvM, it would be useful if there was a way to trigger a snapshot whenever a layer change happens. This would make the videos appear much smoother since you would not see the bed constantly moving up and down.

  • Link to post
    Share on other sites

    Posted · Making Time Lapse Videos with the Ultimaker 3
    Quote

    Yes.

    On Windows, V13 and V14 seem to have this feature (not tried V12 as its quite out of date).

    I didn't notice the feature until I connected an old USB web cam and expected to need to use a separate timelapse program, but a new tab appeared in the Print dialog, showing the a preview and allowing some setting changes like folder to save to and some colour correction stuff (possibly associated with the camera driver)

    However on a print that lasted an hour, the timelapse video only lasted around 10 secs, so I wanted to change how often a picture (frame) was captured.

    Looking on GitHub there are various bits of code that seem to control the timelapse.

    e.g. https://github.com/daid/Cura/search?q=timelapse&ref=cmdform

    https://github.com/daid/Cura/blob/722656b7ba94d44cdfa993e12f50a6285e939e0b/Cura/gui/util/webcam.py

    I've just had a trawl though the code and it looks like this bit of code causes the camer to take a new image

    def mcZChange(self, newZ):

    self.currentZ = newZ

    print 'Z:%f' % newZ

    if self.cam is not None:

    wx.CallAfter(self.cam.takeNewImage)

    wx.CallAfter(self.camPreview.Refresh)

    (see https://github.com/daid/Cura/blob/4d1c0da752fe45ffaf6e9257bd5d1abe86d53fe0/Cura/gui/printWindow.py)

    So I'm no expert, but it appears to be taking a photo every time the Z changes.i.e once per layer, so as my object only has 75 layers and the resultant movie is probably 24 fps, the movie is only just over 3 seconds long (which is a bit short for a 1 hour print :wink:

    I suspect that if its not too much overhear, that perhaps it could be put into

     

    
    
     

    def UpdateProgress(self):

    e.g around line 458, where it appers to get the print time.

     

    
    
     

    printTime = self.machineCom.getPrintTime() / 60

    so we could take a picture every 10 seconds using this code (probably... Note its been a while since I did any python programming :wink:

    if self.cam is not None && printTime%10 == 0:

    wx.CallAfter(self.cam.takeNewImage)

    wx.CallAfter(self.camPreview.Refresh)

     

     

    Edit.

     

    I implemented basically the change I described above, and it appears to work, however I did a print and it hung after about 10 minute.

     

    However I don't think this is necessarily a consequence of taking the timelapse video, as I have issues with power glitches, and in this case I'm fairly sure there was a brownout that hung the print.

     

    So I'll try again today and see if it hangs this time.

     

    Note. Even 10 seconds doesnt give a very long or smooth video, as at 24 fps playback, a photo every 10 secs is 1/240 normal speed, so a 1 hour print is compressed to just 15 seconds, which I think is probably too short, unless the build print is very very long, i.e even a 4 hour print would only produce 1 minute of video.

     

    Probably a better time lapse setting is between 1 and 5 seconds per frame, depending on how long the print is estimated to take.

     

    i.e Perhaps the best way to approach this is to add something to the UI where you enter the desired length of the final video e.g. 1 minute,. and the code calculates how often to take the individual pictures, based on the Estimated Print Time.

     

    ***************+++++++++++++_______________++++++++++*************

     

    @All thanks for contributing to the time lapse topic.

    the above quote discusses a previous built in time lapse capability.

    This would be useful for me as I print and run out of the office.

    Curremtly ,after unclogging, the the nozzle is leaking and it's touch and go.

    I started a print last night with CPE AND TPU and the temp remelted crystal PLA.

    Steam began blowing from the fan and globs of maple syrup randomly smeared early layers.

     

    I had to leave. I'll post the results.

     

    @Unlimited Bacon @MarcoTvM @HarrryPlotter et al:

     

    Wish List

    1. Integrate the layer snapshot timing.

    2. Add uploading of the completed file so no open ports or Pi's are needed. 

     

    Attached is a photo of the plug removed from the nozzle.

    After separating the nozzle I put it in the microwave in a mug of soapy water.

    With bit of coaxing and wiggling it came free.

    IMG_20180222_145908.jpg

  • Link to post
    Share on other sites

    Posted · Making Time Lapse Videos with the Ultimaker 3
    18 hours ago, SowaPowa said:

    ...I'll post the results.

     

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

     

    The CPE printed fairly well the TPU never stood a chance. String city.

    TPU (2) is over 1mm high off the build plate. I'm getting the unrealistic difference message after auto leveling.

    I tried manual for the first time unsuccessfully. I'll wait til the core is swapped out before printing dual core again.

    Great time to play around with the Python code.

     

    Wish List:

    1. Modify @Unlimited Bacon's code to either set layer change capture as default or:

    2. Create Time Function with (2) arguments

     

     

     

    IMG_20180228_150400 (1).jpg

  • Link to post
    Share on other sites

    Posted (edited) · Making Time Lapse Videos with the Ultimaker 3

    I had a play with this over the weekend on my UM3, and after some tinkering got it working (Windows 10). Pretty cool! Thanks to unlimitedbacon for your work.

    Below are some test prints - a 10 hour titanic print, and a 13 hour print of the Dom tower in Utrecht (which I can see from my window). Both in PLA, 0.1 and 0.06 layer height respectively. Theoretically it should be possible to get the script running directly on the olimex board (similar to OctoPrint), which would be good as I wouldn't have to leave my laptop on, but it will take some more tinkering. If anyone has any hints let me know.

     

    ezgif-1-96645580af.gif

    ezgif-1-f9bec72ddb.gif

     

    - Matt

    Edited by maht
  • Link to post
    Share on other sites

    Posted · Making Time Lapse Videos with the Ultimaker 3

    Hi, @Harry Plotter

    thank you for your step by step tutorial.. however I am getting confused in step 6 upward. I still stuck with the "request" not installed. Could you teach me how to do in cmd program as you mention in the tutorial?

    thankyou very much for your help.

    Best,

    Zaqi

  • Link to post
    Share on other sites

    Posted · Making Time Lapse Videos with the Ultimaker 3

    Hi Zaqi,

     

    Sorry for the late repy.

     

    I can try to help you...

     

    First of all --> forget about the "request"-problem. That was my 1 attempt to get the programm running.

     

    You should first download the python-program in the right version for your PC (32-bit, or 64-bit). Then you install this and take the python.exe program to your desktop (with drag & drop if you wish).

    Then you have to download the timelapse.py file and put it on your desktop as well.

    Now you have both files on the desktop. GREAT! So far so good...

    This is now where you start the CMD (command line shell) in your search box (it is located in the lower left section where the start button of the windows is located as well... you will see it. It is a small command line with a loupe next to it. There you write inside cmd. And after you press start a black window will open and you will see a promt line, like "C:USERS\Administrator\" there you have to add the command: "cd desktop" (withouth the "). This will lead you to the desktop where the 2 programms are sitting.

    There you can now activate the timelapse like I described in step 8 and following... then you have to start the print and the program will recognize that and will stard taking pictures every X seconds that you have told it to take one. In the end the program tells the PC to combine those single frame fotos to convert them into one .mp4-File. There is where you will pic it up and enjoy the print in timelapse.

     

    If you have further questions let me know

     

    Greetings Daniel

  • Link to post
    Share on other sites

    Posted · Making Time Lapse Videos with the Ultimaker 3

    Hi @Harry Plotter,

     

    Thanks for your reply..

    First of all, I am super beginner of this stuff, I am sorry if I asked stupid question ?
     

    So, I already did your step by step. However, how to activate the timelapse? where should I write the Host, Delay, and Output? I attached print screen of the problem. Any help would be very appreciated.

     

    Thank you very much,

    Best,

    Zaqi

    dunno.PNG

  • Link to post
    Share on other sites

    Posted · Making Time Lapse Videos with the Ultimaker 3

    Hi zaqi,

     

    nice to hear of you again. So here is what I did. Seeing that you have installed the programms alright it will be only a matter of getting the syntax right..

     

    I now took a screenshot the actual program and made some detailed explanations on how you use the different syntaxes and where they are placed and what exactly they do. If you get it right the programm should wait for you to start the printer and then start taking pictures... I tried everything from each time 1 pic every 30 seconds to 150 secs and they were all good. Only the last numbers only make sense if you got a large print and you want to see it fast in the end. If you want so see where something went wrong it is advised to use smaller numbers e.g. 30-50. Then you see more detail in the building but it will take more time.

     

    Hope you will  get a success this time.

     

    Greetings

     

     

    Daniel

    Detailed syntax explanation.jpg

  • Link to post
    Share on other sites

    Posted · Making Time Lapse Videos with the Ultimaker 3

    Hi Daniel @Harry Plotter,

     

    I am coming back to you.. Thanks for your super explanation. It really helps me a lot. ?
    So, unfortunately, I am still have a "request" problem. It said that no module named 'request'. Does it means I should install 'request' module to my computer?

    Again, thanks in advanced,

    best,
    zaqi

     

    problem.PNG

  • Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    • Our picks

      • UltiMaker Cura 5.7 stable released
        Cura 5.7 is here and it brings a handy new workflow improvement when using Thingiverse and Cura together, as well as additional capabilities for Method series printers, and a powerful way of sharing print settings using new printer-agnostic project files! Read on to find out about all of these improvements and more. 
         
          • Like
        • 13 replies
      • S-Line Firmware 8.3.0 was released Nov. 20th on the "Latest" firmware branch.
        (Sorry, was out of office when this released)

        This update is for...
        All UltiMaker S series  
        New features
         
        Temperature status. During print preparation, the temperatures of the print cores and build plate will be shown on the display. This gives a better indication of the progress and remaining wait time. Save log files in paused state. It is now possible to save the printer's log files to USB if the currently active print job is paused. Previously, the Dump logs to USB option was only enabled if the printer was in idle state. Confirm print removal via Digital Factory. If the printer is connected to the Digital Factory, it is now possible to confirm the removal of a previous print job via the Digital Factory interface. This is useful in situations where the build plate is clear, but the operator forgot to select Confirm removal on the printer’s display. Visit this page for more information about this feature.
          • Like
        • 0 replies
    ×
    ×
    • Create New...