I am working on a python script to calculate the duration of all video files in a directory (and sub-directories, links etc.).
Everything works, my only problem is that the following code produzes a memoryleak. I use this function for every media file to get the duration. And the allocated memory is increases significantly. Like 50 megabytes every second. When the function returns the value the memory is not freed. Even after closing all programs or log out in Windows, the memory is not gone. Only the restart will help.
def probe(vid_file_path):
with subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) as proc:
cmd = ["ffprobe", "-loglevel", "quiet", "-print_format", "json", "-show_format", "-show_streams", vid_file_path]
out, err = proc.communicate()
return json.loads(out)
I spent hours trying to figure out if the problem was with ffprobe or with subprocess. And I think it is ffprobe.
If i do this:
cd "<goto ffprobe directory>"
:start
ffprobe -show_streams "<a video file>"
goto start
in a batch file i can see the memory is increases too.
EDIT1: If you want to test my python script see here: https://pastebin.com/NewBgwia