diff --git a/media/clip1024.flv b/media/clip1024.flv new file mode 100644 index 000000000..964e915fc Binary files /dev/null and b/media/clip1024.flv differ diff --git a/tests/test_VideoClip.py b/tests/test_VideoClip.py index 2305f5daa..f3c7c0bfb 100644 --- a/tests/test_VideoClip.py +++ b/tests/test_VideoClip.py @@ -10,6 +10,7 @@ from moviepy.audio.io.AudioFileClip import AudioFileClip from moviepy.video.fx.speedx import speedx from moviepy.utils import close_all_clips +from moviepy.video.io.ffmpeg_reader import ffmpeg_parse_infos from .test_helper import TMP_DIR @@ -150,5 +151,65 @@ def test_withoutaudio(): close_all_clips(locals()) +def test_write_videofile_default_audio(): + clip = VideoFileClip("media/big_buck_bunny_432_433.webm") + location = os.path.join(TMP_DIR, "test_write_videofile_default_audio.mp4") + clip.write_videofile(location) + d=ffmpeg_parse_infos(location) + assert d['video_found'] + assert d['audio_found'] + + +def test_write_videofile_without_audio(): + clip = VideoFileClip("media/big_buck_bunny_432_433.webm") + location = os.path.join(TMP_DIR, "test_write_videofile_without_audio.mp4") + clip.write_videofile(location, audio=False) + d=ffmpeg_parse_infos(location) + assert d['video_found'] + assert not d['audio_found'] + + +def test_write_videofile_with_audio(): + clip = VideoFileClip("media/big_buck_bunny_432_433.webm") + location = os.path.join(TMP_DIR, "test_write_videofile_with_audio.mp4") + clip.write_videofile(location, audio=True) + d=ffmpeg_parse_infos(location) + assert d['video_found'] + assert d['audio_found'] + + +def test_write_videofile_with_provided_audio(): + clip = VideoFileClip("media/big_buck_bunny_432_433.webm") + location = os.path.join(TMP_DIR, "test_write_videofile_with_provided_audio.mp4") + clip.write_videofile(location, audio="media/crunching.mp3") + d=ffmpeg_parse_infos(location) + assert d['video_found'] + assert d['audio_found'] + + +def test_write_videofile_with_silent_video(): + source = "media/clip1024.flv" + clip = VideoFileClip(source) + d=ffmpeg_parse_infos(source) + assert not d['audio_found'] + location = os.path.join(TMP_DIR, "test_write_videofile_with_silent_video.mp4") + clip.write_videofile(location) + d=ffmpeg_parse_infos(location) + assert d['video_found'] + assert not d['audio_found'] + + +def test_write_videofile_adds_audio_to_silent_video(): + source = "media/clip1024.flv" + clip = VideoFileClip(source) + d=ffmpeg_parse_infos(source) + assert not d['audio_found'] + location = os.path.join(TMP_DIR, "test_write_videofile_adds_audio_to_silent_video.mp4") + clip.write_videofile(location, audio="media/crunching.mp3") + d=ffmpeg_parse_infos(location) + assert d['video_found'] + assert d['audio_found'] + + if __name__ == "__main__": pytest.main()