Skip to content

Commit

Permalink
Rewrite doc for temp_audiofile and auto-convert from path object to…
Browse files Browse the repository at this point in the history
… string.
  • Loading branch information
tburrows13 committed Apr 14, 2020
1 parent 2bd0edd commit 90e85b2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added <!-- for new features -->
- 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 <!-- for changes in existing functionality -->

Expand Down
1 change: 1 addition & 0 deletions moviepy/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__

Expand Down
11 changes: 7 additions & 4 deletions moviepy/video/VideoClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions moviepy/video/tools/subtitles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions tests/test_VideoClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,5 @@ def test_withoutaudio():


if __name__ == "__main__":
#pytest.main()
test_write_videofiles_with_temp_audiofile_path()
# pytest.main()
test_write_videofiles_with_temp_audiofile_path()

0 comments on commit 90e85b2

Please sign in to comment.