def test_issue_922(): import moviepy.video.tools.subtitles as sub tester_subtitles = sub.file_to_subtitles("media/subtitles.srt") index = 0 while index < len(tester_subtitles): assert tester_subtitles[index][0] and tester_subtitles[index][1] index += 1
def test_file_to_subtitles(): from moviepy.video.tools.subtitles import file_to_subtitles data = [([0.0, 4.0], 'Red!'), ([5.0, 9.0], 'More Red!'), ([10.0, 14.0], 'Green!'), ([15.0, 19.0], 'More Green!'), ([20.0, 24.0], 'Blue'), ([25.0, 29.0], 'More Blue!')] assert data == file_to_subtitles("media/subtitles1.srt")
def test_file_to_subtitles(): data = [ ([0.0, 4.0], "Red!"), ([5.0, 9.0], "More Red!"), ([10.0, 14.0], "Green!"), ([15.0, 19.0], "More Green!"), ([20.0, 24.0], "Blue"), ([25.0, 29.0], "More Blue!"), ] assert data == file_to_subtitles("media/subtitles1.srt")
def make_video_with_subtitles(video_path, user_id): generator = lambda txt: moviepy.editor.TextClip( txt, font='Arial', fontsize=30, color='white') sub = file_to_subtitles(MAIN_DIRECTORY + '%d/subtitles.srt' % user_id) subtitles = SubtitlesClip(sub, generator) video = moviepy.editor.VideoFileClip(video_path) result = moviepy.editor.CompositeVideoClip( [video, subtitles.set_position(('center', 'bottom'))]) result.to_videofile(RESULT_DIRECTORY + 'video_%d.mp4' % (user_id), fps=video.fps, audio_codec='libmp3lame', verbose=False, logger=None, temp_audiofile=RESULT_DIRECTORY + 'temp-audio_%d.mp3' % (user_id), remove_temp=True)
def test_file_to_subtitles(): data = [([0.0, 4.0], 'Red!'), ([5.0, 9.0], 'More Red!'), ([10.0, 14.0], 'Green!'), ([15.0, 19.0], 'More Green!'), ([20.0, 24.0], 'Blue'), ([25.0, 29.0], 'More Blue!')] assert data == file_to_subtitles("media/subtitles1.srt")
def test_file_to_subtitles_unicode(): assert MEDIA_SUBTITLES_UNICODE_DATA == file_to_subtitles( "media/subtitles-unicode.srt", encoding="utf-8")
def test_file_to_subtitles(): assert MEDIA_SUBTITLES_DATA == file_to_subtitles("media/subtitles.srt")
def test_file_to_subtitles(): data = [([0.0, 4.0], 'Red!'), ([5.0, 9.0], 'More Red!'), ([10.0, 14.0], 'Green!'), ([15.0, 19.0], 'More Green!'), ([20.0, 24.0], 'Blue'), ([25.0, 29.0], 'More Blue!')] assert data == file_to_subtitles("media/subtitles1.srt")