Skip to content

Instantly share code, notes, and snippets.

@Laurian
Created January 20, 2016 20:18
Show Gist options
  • Select an option

  • Save Laurian/32c39ae896ee8b22fab7 to your computer and use it in GitHub Desktop.

Select an option

Save Laurian/32c39ae896ee8b22fab7 to your computer and use it in GitHub Desktop.

Revisions

  1. Laurian created this gist Jan 20, 2016.
    10 changes: 10 additions & 0 deletions subtitles.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    from moviepy.editor import *
    from moviepy.video.tools.subtitles import SubtitlesClip

    generator = lambda txt: TextClip(txt, font='Arial', fontsize=16, color='white')
    subtitles = SubtitlesClip("somet.srt", generator)

    video = VideoFileClip("some.mp4")
    result = CompositeVideoClip([video, subtitles.set_pos(('center','bottom'))])

    result.write_videofile("out.mp4", fps=video.fps, temp_audiofile="temp-audio.m4a", remove_temp=True, codec="libx264", audio_codec="aac")