Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't unlink file after audio extraction #97

Closed
Eloar opened this issue Dec 5, 2014 · 5 comments
Closed

Can't unlink file after audio extraction #97

Eloar opened this issue Dec 5, 2014 · 5 comments

Comments

@Eloar
Copy link
Contributor

Eloar commented Dec 5, 2014

So I'm downloading mp4 file to temp and extract audio like that:

vc = VideoFileClip(infile)
vc.audio.write_audiofile(outfile)

where infile is full path to tempfile and outfile is full path to mp3 file to save audio to. I can't unlink tempfile after extraction as I get PermissionError. I'm trying to 'destroy' VideoFileClip object:

del vc.audio.reader
del vc.audio
del vc

and it is for nothing. I found out AudioFileClip has no del method so it is good to del it manually (it works in other place in my app).

@Zulko
Copy link
Owner

Zulko commented Dec 6, 2014

I am not sure I understood. What do you mean by unlink ? And by "it is good to del it manually (it work in other place in my app)" ? Can you provide a minimal snippet with what MoviePy does now, and what you would like it to do ?

@Eloar
Copy link
Contributor Author

Eloar commented Dec 6, 2014

When I'm merging ImageSequenceClip with AudioFileClip to create mp4 file I use that code:

def createMovie(sequence_dir, audio_file, outfile, start_time, fps):
    imSeq = ImageSequenceClip(sequence_dir, fps)
    auSeq = AudioFileClip(audio_file)
    imSeq.audio = auSeq.subclip(start_time, imSeq.duration + start_time)
    imSeq.write_videofile(outfile, verbose=False)
    del imSeq.audio
    del imSeq
    del auSeq.reader
    del auSeq
    return outfile

Deleting audio from ImageSequnce deleting reader and audio separately was only way to close audio file. This was temporary file, so I'm deleting it later. I would like to delete mp4 file from which audio was extracted but could not figure out how to do so yet.

@Zulko
Copy link
Owner

Zulko commented Dec 7, 2014

I think I fixed it, can you try the new version (github or PyPI) and tell me if it works ?
This could be linked to that other issue #96 , that I just fixed. In short, a bug made that the clip and it's connection to the file were not deleted at the end of the function execution. From what I have tested, I can now delete the temporary file without any problem.

@Eloar
Copy link
Contributor Author

Eloar commented Dec 8, 2014

Yes, now it works like charm.

@Eloar Eloar closed this as completed Dec 8, 2014
@Zulko
Copy link
Owner

Zulko commented Dec 8, 2014

Good. Cheers !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants