In the line
In the line
subprocess.run(['ffmpeg', '-i', f2, '-ss', '00:00:02', '-vframes', '1', f'{file.name.split(".")[0]}.png'])
file
will be the last file
asigned in the loop by location
as it has not been defined as anything since then.In the line
f2 = list1[int(f1)]
f2
has been assigned as the chosen item from the list and then nothing is done with it.