Creating Time-Lapse Videos in Home Assistant

by Pete
4 minutes read

Time-lapse videos are a captivating way to condense hours, days, or even weeks of events into a short video clip. With the power of Home Assistant and a few simple automations, you can effortlessly create stunning time-lapse videos using the camera feed from your integrated webcam.

In this tutorial, we’ll walk you through the process of setting up two automations in Home Assistant—one to capture snapshots and the other to compile those snapshots into a mesmerizing time-lapse video.


  • Home Assistant installed and configured.
  • Integrated webcam or camera entity set up in Home Assistant. (I’ve used an esp32cam)

Capturing Snapshots and Generating the Video

In the first automation, we’ll set up a routine to capture snapshots at regular intervals. These snapshots will serve as the building blocks for our time-lapse video.

  • Open your Home Assistant user interface.
  • Navigate to “Configuration” > “Automations.”
  • Click on the “+” button to create a new automation.

Automation Configuration: Capturing Snapshots

alias: Timelapse Snapshot
  - platform: time_pattern
    minutes: /10
  - service: camera.snapshot
      filename: >-
        /config/www/snapshots/esp32cam02/esp32cam02_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg
      entity_id: camera.esp32cam02

In this automation, we use the time_pattern trigger to take a snapshot every 10 minutes. Snapshots are saved in the specified directory with a timestamp in the filename.

Automation Configuration: Creating the Time-Lapse Video

The second automation will compile the captured snapshots into a captivating time-lapse video.

alias: Timelapse Video
  - platform: time_pattern
    hours: /1
  - service: shell_command.create_time_lapse
    data: {}

Here, we use the time_pattern trigger to generate a time-lapse video every hour. The shell_command.create_time_lapse service will execute the FFmpeg command to compile the snapshots into a video.

Configure FFmpeg

Make certain to have FFmpeg installed either on the device hosting your Home Assistant or on a machine accessible over your network. Also, remember to tailor the configuration in your configuration.yaml file for shell_command.create_time_lapse to align with your specific FFmpeg command.

  create_time_lapse: 'ffmpeg -framerate 6 -pattern_type glob -i "/config/www/snapshots/esp32cam02/*.jpg" -c:v libx264 -r 6 -pix_fmt yuv420p /config/www/timelapse/esp32cam02_timelapse.mp4'

FFMPEG Command

The ffmpeg command generates the timelapse video using x264 codec and two configuration flags:

  • -framerate 6: This flag specifies the input frame rate, which determines how many input images (snapshots) should be considered per second. This value defines the speed of the video’s playback.
  • -r 6: This flag specifies the output frame rate, which determines how many frames should be included in the output video per second.

If you capture a large number of snapshots in a short period, using a lower value for the frame rate can result in a smoother and slower time-lapse video.


With these two automations, you’ve empowered your Home Assistant setup to capture snapshots and create stunning time-lapse videos effortlessly. This simple yet powerful technique allows you to turn ordinary moments into captivating visual stories.