Created
June 9, 2014 06:07
-
-
Save Zulko/c1e135d2401bed18c5d0 to your computer and use it in GitHub Desktop.
The Turkish March on a computer keyboard - source code of the video editing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# | |
# This is the Python/MoviePy code used to generate | |
# this video of me playing the Turkish March on my | |
# computer's keyboard. Enjoy ! | |
# | |
# https://www.youtube.com/watch?v=z410eauCnHc | |
# | |
from moviepy.editor import * | |
### LOAD FILES | |
keyboard = VideoFileClip("./P1030015.MOV", audio=False) | |
# 2 microphones: computer audio output, and ambient noise | |
audio_ambient = AudioFileClip("./SR018MS.WAV") | |
audio_music = AudioFileClip("./SR018XY.WAV") | |
SIZE = W,H = keyboard.size | |
### ASSEMBLE AUDIO | |
a_start, a_end = 14.5, (2,0) | |
audios = audio_ambient_p, audio_music_p = [ | |
c.subclip(a_start, a_end) | |
.audio_fadein(.2) | |
.audio_fadeout(.2) | |
for c in audio_ambient, audio_music] | |
audio = CompositeAudioClip(audios) | |
### MY PERFORMANCE | |
keyboard_p = (keyboard.subclip(11.6) | |
.set_audio(audio) | |
.set_duration(audio.duration) | |
.fx(vfx.freeze_at_start, .3) | |
.fx(vfx.freeze_at_end, .2, delta=.02) | |
.fadein(1) | |
.fadeout(1)) | |
# 'aarrgh' annotation for the mistake | |
annotation = (TextClip('ARRRGH\n' | |
'SORRY FOR THAT', | |
font = 'Purisa-Bold', | |
kerning=-2.5, | |
interline=-10, | |
fontsize=28) | |
.on_color(color=3*[255], col_opacity=.9, size=(260,85)) | |
.set_pos((W/2, H/2)) | |
.set_start((1,4)) | |
.set_end((1,6.5)) | |
.crossfadein(.5).crossfadeout(.5)) | |
keyboard_annot = CompositeVideoClip([keyboard_p, annotation]) | |
### ASSEMBLE THE TITLE SLIDE | |
title = (TextClip('Turkish March', | |
fontsize=90, | |
font='Amiri-Regular') | |
.set_pos(('center',H/5))) | |
marmotte = (TextClip('Composed by W. A. Mozart\n' | |
'Performed by A. de Lamarmotte\n' | |
'(with apologies)', | |
fontsize=50, | |
interline=-20, | |
font='Amiri-Regular') | |
.set_pos(('center',.4*H))) | |
mozart = (ImageClip("./mozart.jpeg") | |
.resize(.7) | |
.set_pos(('left','bottom'))) | |
title_slide = (CompositeVideoClip([mozart, title, marmotte, ], | |
size= SIZE, | |
bg_color=3*[255]) | |
.to_ImageClip() | |
.set_duration(5) | |
.fadein(1) | |
.fadeout(1)) | |
### ASSEMBLE THE OUTRO SLIDE | |
thanks = (TextClip('Thanks for watching !', | |
fontsize=90, | |
font='Amiri-Regular') | |
.set_pos(('center',.05*H))) | |
descr = (TextClip('Keyboard configuration:', | |
fontsize=50, | |
font='Amiri-Regular') | |
.set_pos(('center',.3*H-10))) | |
txt_keyboard = (ImageClip('./keyboard.png') | |
.resize(width = .65*W) | |
.set_pos(('center',.4*H))) | |
end_slide = (CompositeVideoClip([ | |
thanks, descr, txt_keyboard], | |
size= SIZE, | |
bg_color=3*[255]) | |
.to_ImageClip() | |
.set_duration(6) | |
.fadein(1) | |
.fadeout(1)) | |
### ADD SLIDE: PROUDLY MADE WITH MoviePy :) | |
made_with_moviepy = (ImageClip('./madewith_black.png') | |
.resize(.7) | |
.on_color(color=3*[255], size=SIZE)) | |
grenoble = (TextClip('Grenoble 2014', | |
fontsize=50, | |
color='gray', | |
font='Amiri-Regular') | |
.set_pos(('right','bottom')) | |
.margin(right=20, bottom=10, opacity=0)) | |
made_with_moviepy = (CompositeVideoClip( | |
[made_with_moviepy, grenoble]) | |
.set_duration(3) | |
.fadein(.5) | |
.fadeout(.5)) | |
### CONCATENATE ALL CLIPS | |
final = concatenate([title_slide, | |
keyboard_annot, | |
end_slide, | |
made_with_moviepy]) | |
### RENDER TO A FILE | |
final.to_videofile('turkish_march_on_computer_keyboard.mp4', | |
bitrate='2500k', | |
audio_bitrate='500k', | |
fps=keyboard.fps) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment