I have a Synology NAS running Surveillance Station, and I have a camera configured for Smart Time Lapse which saves an mp4 file to '/volume1/surveillance/@TimeLapse/Smart Timelapse' and a subfolder formatted as YYYYMMDD{AM/PM} depending on when the timelapse begins. I have Smart Time Lapse Task settings configured to create time lapse files over 24-hour durations, where the final video is 1 minute long. The file details are 5120x1552 resolution, 60906 kb/s, 30 fps, and as such are about 500 MB each. Network and power snags can terminate recordings prematurely, so the files aren't always finished at the same time. Furthermore, the files are written in real time, so currently recording time lapses will be in folders titled with dates from today or yesterday. The most recent/current folder/file should not be touched.
I would like to set up an automated task that detects completed time lapse files and encodes them into a smaller file in '/volume1/Files/Video/TimelapseAutomation'. I think that the best detection method would be to recognize when a newer folder/file is created, which would indicate that the second-newest folder/file has just completed recording. I would like new files to begin encoding as soon after their completion as feasible (not something that just checks once every 24 hours). How can I implement this? I realize that this isn't specifically a Home Assistant question, so feel free to direct me elsewhere if necessary.