I have this code:
outtxt = "output2.txt"
command = f"ffprobe -v error -select_streams v:0 -show_entries stream=nb_frames -of default=nokey=1:noprint_wrappers=1 {inputpath}"
with open(outtxt, "w") as output:
subprocess.Popen(command, stdout=output, stderr=output, text=True, creationflags=0x08000000)
output.close()
with open(outtxt, "r") as file:
data = file.read()
print(data)
When I run this, Python only prints a blank line. ("") But there is definitely a file like that and it has a single line content that stores a video file's frame count. 813
But python can't read that line. How can I read the frame count and convert to an integer? (I am on Windows 10)
Edit: Sorry for indentation. I fixed the indentation and wrote my full code. Also, i tried to close the first file but that also didn't work. I checked output2.txt and it is not empty. I deleted and tried again and it was not empty.