Zulko / moviepy

Video editing with Python
https://zulko.github.io/moviepy/
MIT License
12.07k stars 1.51k forks source link

An error occurred in calculating the duration of multiple videos in one folder using VideoFileClip #2099

Open sunpyuser opened 5 months ago

sunpyuser commented 5 months ago

Hello, Thank you for sharing the open source project,when I tried to calculate video duration using VideoFileClip, I found the following code online

1705762950921

The method successfully calculated the duration of a single video, but encountered an error when attempting to calculate the duration of each video in the same folder. like this

1705763191195

My source code

1705763748230 1705763764612

I tried to solve this problem and succeeded.

1705763559245

I think the problem is that VideoFileClip uses a file handle internally to read the video file contents. So after reading the video, i need to close this file handle to free up resources. But why isn't it necessary to close files when processing a single video, Operating system: windows Python version: 3.10 Project version/Commit hash: Latest

keikoro commented 4 months ago

Please always include code samples in the form of code-formatted text, not screenshots. Images of code are very bad practice, see e.g. other platforms like StackOverflow and similar, where this is equally discouraged.