"""make_framelist.py

This script is part of the FFMPEG tutorial for  Kimberly.
It generates a list of images files which are later combining into a movie with ffmpeg.

Usage: `python make_framelist.py`

Author: Pierre DERIAN
"""
import glob
import sys

patterns = [
    '../images/scans/202308/20230818/scan_REAL.20230818_18[3-5]*.png',  #second half-hour of 6PM
    '../images/scans/202308/20230818/scan_REAL.20230818_19*.png',  #every image of 7 PM
    '../images/scans/202308/20230818/scan_REAL.20230818_20[01]*.png',  # first 20 min of 8 PM
]

# Search all patterns, concatenate results in a list
framelist = []
for p in patterns:
    framelist.extend(glob.glob(p))
# Make sure it is sorted
framelist.sort()
print(f'Found {len(framelist)} files matching patterns')
# Write output
output_file = 'framelist.txt'
with open(output_file, 'w') as f:
    for img in framelist:
        f.write(img + '\n')
print('Wrote framelist.txt')

