I am trying to complete this part of my program. In this section, I am trying to speed up or slow down a video based on a factor variable. Once it's done, I use moviepy to turn it into a VideoFileClip, then I delete the file. if factor <= 2: system("ffmpeg -i " + paths[dex] + " -vf setpts=" + str(vfactor) + "*PTS -an ./Media/Videos/temp.mp4") system("ffmpeg -i " + paths[dex] + " -filter:a atempo=" + str(factor) + " -vn ./Media/ShortSounds/temp.mp3") elif 2 < factor < 4: factor = round(sqrt(factor), 1) system("ffmpeg -i " + paths[dex] + " -vf setpts=" + str(vfactor) + "*PTS,setpts=" + str(vfactor) + "*PTS -an ./Media/Videos/temp.mp4") system("ffmpeg -i " + paths[dex] + " -filter:a atempo=" + str(factor) + ",atempo=" + str(factor) + " -vn ./Media/ShortSounds/temp.mp3") elif factor > 4: raise Exception("File " + paths[dex] + " is too long.") t = VideoFileClip("./Media/Videos/temp.mp4") t.audio = AudioFileClip("./Media/Videos/temp.mp3") templist.append(t) remove("./Media/Videos/temp.mp4") However, when the code gets to the deletion command, it has the following error: PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: './Media/Videos/temp.mp4' What's strange is, I can see the temp.mp4 file, and it runs just fine. I never get this error while manually running the temp.mp4 file. I have tried the following: Waiting 5, 10, and 20 seconds before deleting the file. Running "taskkill -f -im ffmpeg.exe" before deleting the file I went through the debugger, and right before the deletion, I checked in task manager to see if ffmpeg was still running, and it wasn't. Do you guys have any idea what could be holding this up? My code worked previously when I was trying to just do audio, but I am trying it with video and this is happening. Continue reading...