sciactive / pulverize

A multi-process rendering script for Blender VSE.
GNU General Public License v2.0
60 stars 13 forks source link

ffmpeg doesn't like the generated pulverize_input_files.txt generated on windows #6

Closed carc1n0gen closed 4 years ago

carc1n0gen commented 7 years ago

My generated pulverize_input_files.txt file looks like this:

file /tmp\pulverize_frames_0000317-0000502.mp4
file /tmp\pulverize_frames_0000503-0000688.mp4
file /tmp\pulverize_frames_0000689-0000874.mp4
file /tmp\pulverize_frames_0000875-0001060.mp4
file /tmp\pulverize_frames_0001061-0001246.mp4
file /tmp\pulverize_frames_0001247-0001432.mp4
file /tmp\pulverize_frames_0001433-0001618.mp4
file /tmp\pulverize_frames_0001619-0001807.mp4

ffmpeg seems to interpret the \ as an escape sequance with the p next to it. Manually adding a second \ and calling the ffmpeg command manually works.

I was looking for a solution to make this not a manual process and I came up with changing the join code as follows:

with open(file_list, 'w') as fp:
        fp.write('\n'.join(["file %s" % x.replace('\\', '\\\\') for x in chunk_files]))

But I do not think this is idea because I believe this will now only work on windows. On Linux I believe \ is used to escape spaces in file names and my change might break it.

I'm looking for feedback so I can contribute a PR with a good fix.

hperrin commented 7 years ago

Are you using the PHP script or the Python script? I can fix the PHP one if that's the problem. PHP has a DIRECTORY_SEPARATOR constant. I don't know how to do it in Python.

carc1n0gen commented 7 years ago

@hperrin I'm using the python script, which already does use native directory separator. The problem is that on windows the directory separator is \, which is also the same character used for escape sequences (\n, \t, etc...). So when ffmpeg reads the paths and the path was C:\\some\random\path, it will interpret \s, \r, and \p as escape sequences and then ffmpeg can't find the files to merge together because those are invalid and ignored escape sequences and the path gets interpreted as C:\\someandomath

hperrin commented 6 years ago

Hmm. Ok. Would always using a forward slash work? (I don't use Windows, so I don't know much about coding on it.)