diff --git a/CHANGELOG.md b/CHANGELOG.md index 41ec33372..f405b18bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Optional `encoding` parameter in `SubtitlesClip` [#1043] - Support for path-like objects as an option wherever filenames are passed in as arguments +- New `temp_audiofile_path` parameter in `VideoClip.write_videofile()` to specify where the temporary audiofile should be created ### Changed diff --git a/moviepy/decorators.py b/moviepy/decorators.py index 91d021dee..436e7aba5 100644 --- a/moviepy/decorators.py +++ b/moviepy/decorators.py @@ -76,6 +76,7 @@ def audio_video_fx(f, clip, *a, **k): def preprocess_args(fun, varnames): """ Applies fun to variables in varnames before launching the function """ + def wrapper(f, *a, **kw): func_code = f.__code__ diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.py index 1ba54b0ff..fc9291bf0 100644 --- a/moviepy/video/VideoClip.py +++ b/moviepy/video/VideoClip.py @@ -140,7 +140,7 @@ def save_frame(self, filename, t=0, withmask=True): @requires_duration @use_clip_fps_by_default @convert_masks_to_RGB - @convert_path_to_string(["filename", "temp_audiofile_path"]) + @convert_path_to_string(["filename", "temp_audiofile", "temp_audiofile_path"]) def write_videofile( self, filename, @@ -222,8 +222,8 @@ def write_videofile( frame rate to use when generating the sound. temp_audiofile - the name of the temporary audiofile to be generated and - incorporated in the the movie, if any. + the name of the temporary audiofile, as a string or path-like object, to be created and + then used to write the complete video, if any. temp_audiofile_path the location that the temporary audiofile is placed, as a @@ -310,7 +310,10 @@ def write_videofile( audiofile = temp_audiofile elif make_audio: audio_ext = find_extension(audio_codec) - audiofile = os.path.join(temp_audiofile_path, name + Clip._TEMP_FILES_PREFIX + "wvf_snd.%s" % audio_ext) + audiofile = os.path.join( + temp_audiofile_path, + name + Clip._TEMP_FILES_PREFIX + "wvf_snd.%s" % audio_ext, + ) # enough cpu for multiprocessing ? USELESS RIGHT NOW, WILL COME AGAIN # enough_cpu = (multiprocessing.cpu_count() > 1) diff --git a/moviepy/video/tools/subtitles.py b/moviepy/video/tools/subtitles.py index d0dcd30a2..c5c8c072b 100644 --- a/moviepy/video/tools/subtitles.py +++ b/moviepy/video/tools/subtitles.py @@ -150,6 +150,7 @@ def write_srt(self, filename): with open(filename, "w+") as f: f.write(str(self)) + @convert_path_to_string("filename") def file_to_subtitles(filename, encoding=None): """ Converts a srt file into subtitles. diff --git a/tests/test_VideoClip.py b/tests/test_VideoClip.py index bd1e3b52a..5cf244ab9 100644 --- a/tests/test_VideoClip.py +++ b/tests/test_VideoClip.py @@ -176,5 +176,5 @@ def test_withoutaudio(): if __name__ == "__main__": - #pytest.main() - test_write_videofiles_with_temp_audiofile_path() \ No newline at end of file + # pytest.main() + test_write_videofiles_with_temp_audiofile_path()