OpenGenus / vidsum

Generate summary of any video :tv: anywhere and anytime
GNU General Public License v3.0
262 stars 69 forks source link

WindowsError: Can't remove file #38

Closed lwgray closed 7 years ago

lwgray commented 7 years ago

Expected Behavior

We expect sum.py to delete original mp4 and srt files unless otherwise specified

Current Behavior

Traceback (most recent call last): File "sum.py", line 252, in os.remove(movie_filename) WindowsError: [Error 32] The process cannot access the file because it is being used by another process: u'1.mp4'

Possible Solution

I do not know 😞

Steps to Reproduce the Problem

  1. Git clone vidsum onto windows machine
  2. pip install -r requirements.txt
  3. python sum.py -u https://www.youtube.com/watch?v=xRJCOz3AfYY

Detailed Description

Upon running sum.py on a windows 10 platform, the script is interrupted with a windowsError stating that the removal of files can't take place because one of the file is still in use.

Specifications

AdiChat commented 7 years ago

Cause of error:

VideoFileClip() of moviepy library

The error arises at Line 153: input_video = VideoFileClip(filename)

A detailed discussion regarding this behaviour exists at moviepy repository: see this

Possible solution

The immediate solution, in my opinion, would be to generate the summarized video in a child process that is: execute the statement (Line 244) get_summary(filename=movie_filename, subtitles=subtitle_filename) in a child process and kill the process immediately after its execution that is before we attempt to delete the download files.

ilimugur commented 7 years ago

I'd like to work on this, unless the issue is already taken.

AdiChat commented 7 years ago

Sure @ilimugur Go ahead 👍

ilimugur commented 7 years ago

Ahead I went, and created a pull request. Tried the fix on a machine running Windows and it seems to have fixed the issue.