Skip to content

Instantly share code, notes, and snippets.

@Laurian
Created January 20, 2016 20:18
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Laurian/32c39ae896ee8b22fab7 to your computer and use it in GitHub Desktop.
Save Laurian/32c39ae896ee8b22fab7 to your computer and use it in GitHub Desktop.
movie.py subtitles example
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")
@lucasbracher
Copy link

Hi! First of all, thank you for this nice script!

At first I wasn't able to run it, so I used this solution and now it works! https://askubuntu.com/questions/873112/imagemagick-cannot-be-detected-by-moviepy/873124 https://askubuntu.com/questions/873112/imagemagick-cannot-be-detected-by-moviepy/873124

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment