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

fix PermissionError in Windows #16

Open
wants to merge 2 commits into
base: fix/windows_cutting
Choose a base branch
from

Conversation

moon-jam
Copy link

@moon-jam moon-jam commented Jul 1, 2024

Related Issues: #6 #7

  • Run properly on Windows 11
  • Run properly on Ubuntu 22.04 (on WSL2)

I encountered an issue while running the script where temporary filter files were not being properly cleaned up, leading to a PermissionError. To resolve this, I made the following changes:

  1. Prepare Filter Files with delete=False:

    • Changed the creation of temporary files for video and audio filters to include the delete=False parameter. This ensures that the files are not deleted immediately upon closure, allowing FFmpeg to access them properly.
    vFile = tempfile.NamedTemporaryFile (mode="w", encoding="UTF-8", delete=False, prefix="silence_video")
    aFile = tempfile.NamedTemporaryFile (mode="w", encoding="UTF-8", delete=False, prefix="silence_audio")
  2. Ensure FFmpeg Completes Execution:

    • Added check=True to the subprocess.run call to ensure that FFmpeg completes execution before the script proceeds. This helps in catching errors early and ensuring that the resources are properly released.
    subprocess.run (command, check=True)
  3. Properly Remove Temporary Files:

    • Explicitly removed the temporary files after FFmpeg completes execution to ensure proper cleanup of resources and avoid any PermissionError.
    os.remove(videoFilter_file)
    os.remove(audioFilter_file)

@DarkTrick
Copy link
Owner

I didnt forget this, but the merge will take time :( 🙇

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

Successfully merging this pull request may close these issues.

2 participants