Skip to content

Commit

Permalink
Merge pull request #458 from Gloin1313/complement#380
Browse files Browse the repository at this point in the history
Adds `progress_bar` option to `write_audiofile()` to complement #380
  • Loading branch information
Gloin1313 committed Mar 6, 2017
2 parents 407cbd7 + 49e49ec commit d5788cb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
19 changes: 11 additions & 8 deletions moviepy/audio/AudioClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,10 @@ def max_volume(self, stereo=False, chunksize=50000, progress_bar=False):

@requires_duration
def write_audiofile(self,filename, fps=44100, nbytes=2,
buffersize=2000, codec=None,
bitrate=None, ffmpeg_params=None,
write_logfile=False, verbose=True):
buffersize=2000, codec=None,
bitrate=None, ffmpeg_params=None,
write_logfile=False, verbose=True,
progress_bar=True):
""" Writes an audio file from the AudioClip.
Expand Down Expand Up @@ -186,7 +187,9 @@ def write_audiofile(self,filename, fps=44100, nbytes=2,
verbose
If True, displays informations
progress_bar
If False, will not display the red progress bar
"""

Expand All @@ -200,11 +203,11 @@ def write_audiofile(self,filename, fps=44100, nbytes=2,
"write_videofile.")

return ffmpeg_audiowrite(self, filename, fps, nbytes, buffersize,
codec=codec, bitrate=bitrate, write_logfile=write_logfile,
verbose=verbose, ffmpeg_params=ffmpeg_params)
codec=codec, bitrate=bitrate, write_logfile=write_logfile,
verbose=verbose, ffmpeg_params=ffmpeg_params,
progress_bar=progress_bar)


###
#
# The to_audiofile method is replaced by the more explicit write_audiofile.
AudioClip.to_audiofile = deprecated_version_of(AudioClip.write_audiofile,
'to_audiofile')
Expand Down
9 changes: 4 additions & 5 deletions moviepy/audio/io/ffmpeg_audiowriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def close(self):
def ffmpeg_audiowrite(clip, filename, fps, nbytes, buffersize,
codec='libvorbis', bitrate=None,
write_logfile = False, verbose=True,
ffmpeg_params=None):
ffmpeg_params=None, progress_bar=True):
"""
A function that wraps the FFMPEG_AudioWriter to write an AudioClip
to a file.
Expand All @@ -155,11 +155,10 @@ def ffmpeg_audiowrite(clip, filename, fps, nbytes, buffersize,
logfile=logfile,
ffmpeg_params=ffmpeg_params)



for chunk in clip.iter_chunks(chunksize=buffersize,
progress_bar=True, quantize=True,
nbytes= nbytes, fps=fps):
quantize=True,
nbytes= nbytes, fps=fps,
progress_bar=progress_bar):
writer.write_frames(chunk)

"""
Expand Down
5 changes: 3 additions & 2 deletions moviepy/video/VideoClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ def write_videofile(self, filename, fps=None, codec=None,
These will be files ending with '.log' with the name of the
output file in them.
progress_bar
If false, will not display the red progress bar
Examples
========
Expand Down Expand Up @@ -326,7 +327,7 @@ def write_videofile(self, filename, fps=None, codec=None,
audio_nbytes, audio_bufsize,
audio_codec, bitrate=audio_bitrate,
write_logfile=write_logfile,
verbose=verbose)
verbose=verbose, progress_bar=progress_bar)

ffmpeg_write_video(self, filename, fps, codec,
bitrate=bitrate,
Expand Down
4 changes: 4 additions & 0 deletions tests/test_PR.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,9 @@ def test_PR_424():
clip = ColorClip([1000, 600], color=(60, 60, 60), duration=10, col=(2,2,2))


def test_PR_458():
clip = ColorClip([1000, 600], color=(60, 60, 60), duration=10)
clip.write_videofile("test.mp4", progress_bar=False, fps=30)

if __name__ == '__main__':
pytest.main()

0 comments on commit d5788cb

Please sign in to comment.