DarkTrick / python-video-silence-cutter

Python script, that uses ffmpeg and ffprobe to cut silences away from videos
Creative Commons Zero v1.0 Universal
43 stars 16 forks source link

Not compatible with Windows #5

Closed simonflick closed 1 year ago

simonflick commented 2 years ago

The script didn't work on my Windows machine because of two things:

  1. Windows has \r\n line endings
  2. NamedTemporaryFile doesn't work on Windows

To work around these issues I hacked together these changes: Use RegEx to replace both line ending formats

lines = re.split(r"(\\r)?\\n", s)

Create temp files manually in the execution dir and remove afterwards

vFileName = outfile + ".tempvideo"
aFileName = outfile + ".tempaudio"
vFile = open(vFileName, "w")
aFile = open(aFileName, "w")

# delete temp files at the end
if os.path.exists(vFileName):
  os.remove(vFileName)
if os.path.exists(aFileName):
  os.remove(aFileName)

I also created this batch file

@echo off
echo.
python3 "%~dp0\silence_cutter.py" %*

This is useful because it allows you to put everything into a folder, add it to the path variable and call it via CMD like a normal program.

DarkTrick commented 2 years ago

Thank you for working on this script!

@Script improvements: If you put the upper part into a clean merge request, I'll take a closer look and merge it.

@Batch file: Maybe also worth adding to the directory. Merge request? Although, I'm not sure about your python3:

  1. Does python install itself by default in the path variable on Windows machines?
  2. Does python install itself by default as python3 on Windows machines?

If any questions answeres no, your instructions are probably better suited for the README

DarkTrick commented 1 year ago

Probably related: https://github.com/DarkTrick/python-video-silence-cutter/issues/6

Maybe the branch fix/windows_cutting fixes the problem. You can get the file via git clone -b fix/windows_cutting https://github.com/DarkTrick/python-video-silence-cutter.git

I'll close the issue, as it's probably overlapping with the other issues. Feel free to re-open.