How to take the contents of a folder (.jpegs) and create a timelapse with it in Home Assistant

Please forgive me, I’m new to HA…

I’d like to run an automation at 11:59PM each day. This automation should have a path provided to a collection of images for that particular day. The automation should compile every file (.jpeg) into an .mp4 or .avi file.

The generation of images is going well. I use motionEye and the ESP32_Cam is feeding the selected folder images as expected. I feel like I am close. Here is what I have now:

[In my configuration.yaml file]
shell_command:
  create_timelapse: ffmpeg -pattern_type glob -i "/media/esp32cam/{{ now().strftime("%Y%m%d") }}/*.jpg" \ -c:v libx264 -vf fps=25,format=yuv420p \ "/media/esp32cam/{{ now().strftime("%Y%m%d") }}_timelapse.mp4"

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

[In my automation.yaml file]
alias: 'Snap a Pic Every 1 min'
description: 'Every minute, snap a pic. This shall run from sunrise to sunset. Save pics to a folder with todays date. Label files in dates folder with Year/Month/Day-Hours/Min/Sec.'
trigger:
  - platform: time_pattern
    minutes: /1
condition:
  - condition: sun
    after: sunrise
    before: sunset
action:
  - service: camera.snapshot
    target:
      entity_id: camera.esp_cam3
    data:
      filename: >-
        /media/esp32cam/{{ now().strftime("%Y%m%d") }}/esp32cam_{{    
        now().strftime("%Y%m%d-%H%M%S") }}.jpg
mode: single

- id: '[a_random_id]'
  alias: Create Timelapse Automation
  description: ''
  trigger:
  - platform: time_pattern
    hours: '23'
    minutes: '59'
  condition: []
  action:
  - service: shell_command.create_timelapse
  mode: single

It seems my first issue is here (running it via console from root dir):

➜  / ffmpeg -pattern_type glob -i "/media/esp32cam/{{ now().strftime("%Y%m%d") }}/*.jpg" \ -c:v libx264 -vf fps=25,format=yuv420p \ "/media/esp32cam/{{ now().strftime("%Y%m%d") }}_timelapse.mp4"
zsh: command not found: ffmpeg
➜  / 

I also have this configured in configuration.yaml… not sure if it is doing much:

ffmpeg:
  ffmpeg_bin: /usr/bin/ffmpeg


General notes/ Sys specs:

System Health

version: core-2021.6.6
installation_type: Home Assistant OS
dev: false
hassio: true
docker: true
virtualenv: false
python_version: 3.8.9
os_name: Linux
os_version: 5.10.45
arch: x86_64
timezone: America/New_York


GitHub API: ok
Github API Calls Remaining: 4998
Installed Version: 1.13.2
Stage: running
Available Repositories: 907
Installed Repositories: 22


logged_in: false
can_reach_cert_server: ok
can_reach_cloud_auth: ok
can_reach_cloud: ok


host_os: Home Assistant OS 6.1
update_channel: stable
supervisor_version: supervisor-2021.06.8
docker_version: 20.10.6
disk_total: 30.8 GB
disk_used: 8.0 GB
healthy: true
supported: true
board: ova
supervisor_api: ok
version_api: ok
installed_addons: motionEye (0.14.0), Samba share (9.5.1), Home Assistant Google Drive Backup (0.104.3), Visual Studio Code (3.5.0), Node-RED (9.2.0), ESPHome (1.20.4), Let's Encrypt (4.11.0), Terminal & SSH (9.1.3)


dashboards: 2
resources: 5
views: 7
mode: storage
2 Likes

Have you found a solution? I have the same problem with ffmpeg