Jul-24-2020, 06:15 PM
(This post was last modified: Jul-24-2020, 06:15 PM by pythonnewbie138.)
I'm having trouble getting my user input into a subprocess command. Everything seems to work fine until it takes the screenshot and it ends up choosing the last item in the list instead of the entered number. I have 4 files in the folder that fit the endswith requirement and they all print correctly. Any help with this would be much appreciated.
import os
import subprocess
user_choice = input("Enter a directory: ")
location = os.scandir(user_choice)
list1 = []
for file in location:
if file.name.endswith(('.mp4', '.mkv')):
list1.append(file.name)
for count, ele in enumerate(list1, 1):
print(str(count) + ".", ele)
f1 = input("Select a file: ")
f2 = list1[int(f1)]
subprocess.run(['ffmpeg', '-i', f2, '-ss', '00:00:02', '-vframes', '1', f'{file.name.split(".")[0]}.png'])
