{ "metadata": { "name": "", "signature": "sha256:0c4b6bae19e4c6359624d84a4b832761ea5ea63a6ec0049cd2d74e6a5f188792" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "THE CUP SONG COVERS MIX" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook contains the Python code that generated this video:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from IPython.display import HTML\n", "HTML(\"\"\" \"\"\")\n" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ " " ], "metadata": {}, "output_type": "pyout", "prompt_number": 2, "text": [ "" ] } ], "prompt_number": 2 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Foreword" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The code uses [MoviePy](http://zulko.github.io/moviepy/), a Python library for video editing. You can see most of the most basic capabilities of the library in this video: cuts, concatenations, resizing, fade-in/fade-out effects, texts, etc. Just for fun I also added a few not-so-basic effects like video clips with changing positions.\n", "\n", "MoviePy is well suited for simple and automotizable operations, as well as advanced, customized effects, but this video, by its length and complexity, is an extreme example of what you would do with it. So if you like elegant and concise code, don't look down !\n", "\n", "For info, the generation of this 2 minutes video takes 10-15 minutes on my laptop, most of the computation time being spent to resize the different video clips.\n", "\n", "Using scripts to edit a music video is not necessarily a good idea, but it has its perks: in this video the end credits are automatically generated from the list of videos used by the script, and that list is obtained by parsing... the script itself ! In other words, the code is reading itself ! This way I am sure that no one is forgotten in the credits.\n" ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Imports and functions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here begins the code. It is organized by parts. In each part we first load the video clips from files:\n", "\n", " kara = VideoFileClip(... # Video of Kara\n", " kid = VideoFileClip(... # Video of a kid\n", "\n", "Later, we edit these clips (cut, transitions, fade-ins, etc.):\n", "\n", " kara_p = ( kara.subclip(0.55,4.45)\n", " .reW()\n", " .crop(y2=H)\n", " .fadein(0.5) )\n", "\n", "\n", " kid_p= kid.subclip(1.35,1.85)...\n", "\n", "Then we assemble the clips into a big composition:\n", " first_verse = CompositeVideoClip([kara_p, kid_p...])\n", " " ] }, { "cell_type": "code", "collapsed": false, "input": [ "from moviepy.editor import *\n", "import os \n", "import re # to parse this file to make the credits\n", "\n", "\n", "W, H = 720, 404 # dimensions of the final video\n", "\n", "# These very useful functions resize the clips to\n", "# the dimensions of the final video\n", "\n", "VideoFileClip.reW = lambda clip : clip.resize(width=W)\n", "VideoFileClip.reH = lambda clip : clip.resize(height=H)\n" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 3 }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Title Screen" ] }, { "cell_type": "code", "collapsed": false, "input": [ "theCupSong = TextClip('The Cup Song\\nYoutube Covers Mix',\n", " fontsize=50,\n", " font=\"Ubuntu-Regular\",\n", " color = 'white')\\\n", " .set_pos(('center', 0.24*H))\n", "\n", " \n", "editedby = TextClip('Edited by A. de Lamarmotte',\n", " fontsize=28,\n", " font=\"Ubuntu-Regular\",\n", " color = 'gray')\\\n", " .set_pos(('center', 0.58*H))\n", "\n", "\n", "titleScreen = CompositeVideoClip([theCupSong, editedby],\n", " size = (W,H))\\\n", " .set_duration(3)\\\n", " .fadeout(0.5)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 4 }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "First Rythm" ] }, { "cell_type": "code", "collapsed": false, "input": [ "kara = VideoFileClip(\"./girl_acapella/xkaraxmusicx.mp4\")\n", "kid = VideoFileClip(\"./male/DrewMannMusic.mp4\")\n", "talia = VideoFileClip(\"./girl_acapella/taliajoy18.mp4\")\n", "jencar = VideoFileClip(\"./male/hoorahjencar.mp4\")\n", "riley = VideoFileClip(\"./girl_acapella/hoosierfamily.mp4\")\n", "clown = VideoFileClip(\"./girl_acapella/salvadorzepeda68.mp4\")\n", "nicoleKim = VideoFileClip(\"./girl_acapella/NicoleKim.mp4\")" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 5 }, { "cell_type": "code", "collapsed": false, "input": [ "kara_p = ( kara.subclip(0.55,4.45)\n", " .reW()\n", " .crop(y2=H)\n", " .fadein(0.5) )\n", "\n", "\n", "kid_p= ( kid.subclip(1.35,1.85)\n", " .crop(x1=44, x2=-45)\n", " .reH()\n", " .set_pos('left')\n", " .margin( right=2, color=3*[255])\n", " .volumex(1.5) )\n", " \n", " \n", "talia_p = (talia.subclip(3.53,4)\n", " .reH()\n", " .crop(x1=22, x2=-22)\n", " .set_pos((kid_p.w-2,0))\n", " .margin( right=2, left=2, color=3*[255]) )\n", " \n", " \n", "jencar_p = ( jencar.subclip(1.79,2.23)\n", " .crop( x1=241, x2=-242)\n", " .reH()\n", " .margin(right=2, left=2, color=3*[255])\n", " .set_pos(( kid_p.w + talia_p.w-4 ,0))\n", " .volumex(0.7) )\n", " \n", " \n", "riley_p = (riley.subclip(9.25,9.75)\n", " .crop( x1=20, x2=-47)\n", " .reH()\n", " .margin(left=2, color=3*[255])\n", " .set_pos((jencar_p.w + kid_p.w + talia_p.w-6,0)) )\n", "\n", "clown_p = (clown.subclip(6.6,7.1)\n", " .crop( x1=410, x2=-550)\n", " .reH()\n", " .margin(left=2, right=2, color=3*[255]))\n", "clown_p = clown_p.set_pos((riley_p.pos(0)[0] - clown_p.w+2,0))\n", "\n", "\n", "nicoleKim_p = ( nicoleKim.subclip(7.4,8.0)\n", " .reH()\n", " .crop( x1=280,x2=280+W/4 )\n", " .margin( left=2, right=2, color=3*[255])\n", " .set_pos((W/4,0)) )" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 6 }, { "cell_type": "code", "collapsed": false, "input": [ "d = 0.52\n", "cc = CompositeVideoClip([\n", " kid_p,\n", " talia_p.set_start(d+.01),\n", " jencar_p.set_start(2*d+.00),\n", " nicoleKim_p.set_start(5*d),\n", " clown_p.set_start(4*d),\n", " riley_p.set_start(3*d-.01)],\n", " size=(W,H))\n", "\n", "first_rythm = concatenate([kara_p, cc])" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 7 }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "VERSE 1" ] }, { "cell_type": "code", "collapsed": false, "input": [ "anna = VideoFileClip(\"./girl_acapella/Anna Burden.mp4\")\n", "malia = VideoFileClip(\"./girl_acapella/MaliaRogersMusic.mp4\")\n", "\n", "halie = VideoFileClip(\"./girl_acapella/Halie Ranee.mp4\")\n", "cooper = VideoFileClip(\"./girl_acapella/eveecooper.flv\")\n", "speedstack = VideoFileClip(\"./girl_acapella/theaterobsession101.mp4\")\n", "\n", "\n", "faraz = VideoFileClip(\"./male/Faraz Sabir.mp4\")\n", "amyspants = VideoFileClip(\"./amyspants.mp4\")\n", "\n", "miriam = VideoFileClip(\"./girl_acapella/Miriam Carone.mp4\")\n", "kristina = VideoFileClip(\"./girl_acapella/Kristina G.mp4\")\n", "irene = VideoFileClip(\"./girl_acapella/Irene Poon.mp4\")\n", "\n", "two_little_girls = VideoFileClip(\"./duet/MuggleSam.mp4\")\n", "school_choir_PS22 = VideoFileClip(\"./choir/PS22 Chorus.mp4\")\n", "piano = VideoFileClip(\"./instrumental/Jasper Tan.mp4\")\n", "shae = VideoFileClip(\"./uke_guitar_song/McKenna Shae.mp4\")" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 8 }, { "cell_type": "code", "collapsed": false, "input": [ "from scipy.interpolate import interp1d\n", "\n", "# These complicated interpolation define the movement of the clip\n", "\n", "anna1 = interp1d([-1,1.0,2,8.1,8.8,11.0,11.4,22],\n", " [190,190,112,112,190,190,170,170])\n", "\n", "anna2 = interp1d([-1,1.0,2,8.1,8.8,11.0,11.4,22],\n", " [190+W/4,190+W/4,112+W/2,112+W/2,\n", " 190+W/4,190+W/4,170+W/3,170+W/3])\n", "\n", "\n", "anna_p = (anna\n", " .subclip(8)\n", " .reH()\n", " .fl(lambda gf,t: gf(t)[:,int(anna1(t)):int(anna2(t))])\n", " .volumex(1.2)\n", " .set_duration(18)\n", " .set_pos(lambda t:(\"left\" if (t<11.0) else \n", " min(480,1000*(t-11.0)),0)))\n", "\n", "\n", "malia_p = (malia\n", " .reH()\n", " .subclip(17.18)\n", " .crop(x1=185,x2=185+W/2)\n", " .margin(left=3,color= (255,255,255))\n", " .set_pos(\"right\")\n", " .volumex(0.8)\n", " .set_start(anna_p.start+ 4.65)\n", " .set_end(anna_p.start+8.8))" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 9 }, { "cell_type": "code", "collapsed": false, "input": [ "cooper_p = (cooper.crop(y1=50)\n", " .reH()\n", " .crop(x1=304, x2 = 304+W/4)\n", " .margin(left=1,right=1,color=3*[255])\n", " .subclip(13.65)\n", " .volumex(0.6)\n", " .set_start(anna_p.start+8.1)\n", " .set_end(anna_p.start+10.3))\n", " \n", "ww = cooper_p.w\n", "cooper_p = cooper_p.set_pos(lambda t:(W-2*ww,min(0,1000*t-H)))\n", "\n", "\n", "halie_p = (halie.subclip(15.6)\n", " .reH()\n", " .crop(x1=258, x2 = 258+W/4)\n", " .margin(left=1,right=1,color=3*[255])\n", " .volumex(0.6)\n", " .set_start(anna_p.start+8.1)\n", " .set_end(anna_p.start+10.3)\n", " .set_pos(lambda t:(W-3*ww,max(0,H-1000*t))))\n", "\n", " \n", "speed_stack_p = (speedstack.subclip(35.27)\n", " .reH()\n", " .crop(x1=160, x2 = 160+W/4)\n", " .margin(left=1,color=3*[255])\n", " .volumex(0.6)\n", " .set_start(anna_p.start+8.1)\n", " .set_end(anna_p.start+10.3)\n", " .set_pos(lambda t:(W-ww,max(0,H-1000*t))))\n", "\n", " \n", "faraz_p = (faraz.subclip(25.9)\n", " .reH()\n", " .crop( x1=100, x2=100+3*W/4)\n", " .fl(lambda gf, t: gf(t)[:,(0 if (t<0.9) else\n", " int(1000*(t-0.9))):])\n", " .fadeout(0.2)\n", " .crossfadein(0.2)\n", " .volumex(2.4)\n", " .set_start(anna_p.start+10.1)\n", " .set_end(anna_p.start+11.6)\n", " .audio_fadeout(0.1)\n", " .set_pos('right'))\n", "\n", "\n", "amyspants_p = (amyspants\n", " .subclip(19.4,22)\n", " .margin(12,color=(255,255,255))\n", " .resize( width=2*W/3-20)\n", " .set_pos((10,'center'))\n", " .fadein( 0.5)\n", " .fadeout( 0.5)\n", " .audio_fadein(0.3)\n", " .set_start(anna_p.start+12.29))" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 10 }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "CHORUS 1" ] }, { "cell_type": "code", "collapsed": false, "input": [ "shae_p = (shae\n", " .subclip(25.6)\n", " .reH()\n", " .crop(x1=240, x2 = 240+W/3)\n", " .margin(right=3, color=(255,255,255))\n", " .audio_fadein(0.7)\n", " .volumex(0.6)\n", " .set_start(anna_p.start+16.1)\n", " .set_end(anna_p.start+22)\n", " .audio_fadeout(0.3) \n", " .set_pos(lambda t:(min(240,-240+1000*t),0)) )\n", " \n", " \n", "two_little_girls_p = (two_little_girls\n", " .subclip(34.25)\n", " .reH()\n", " .crop(x1=170, x2=170+360+60)\n", " .margin( right=2, color=(255,255,255))\n", " .set_start(anna_p.start+14.9)\n", " .set_end(anna_p.start+23.5)\n", " .audio_fadeout(0.5)\n", " .set_pos( lambda t:( -180 if t<5.3 else\n", " min(0,-150+500*(t-5.3)),0)))\n", " \n", " \n", "school_choir_PS22_p = (school_choir_PS22\n", " .reH()\n", " .volumex(0.3)\n", " .subclip(29.6)\n", " .crop(x1=140, x2=140+W/2)\n", " .set_start(anna_p.start+16.24)\n", " .set_end(anna_p.start+24.5)\n", " .audio_fadeout(0.5)\n", " .margin(left=3,color=(255,255,255))\n", " .crossfadein( 2)\n", " .fadeout(0.5)\n", " .set_pos(lambda t:(W-240 if t<4 else\n", " max(W/2,W-240-500*(t-4)),0)) )\n", "\n", "\n", "### PIANO\n", "\n", "\n", "piano_p = (piano\n", " .subclip(43,53.1)\n", " .reW()\n", " .set_pos(\"bottom\")\n", " .crop(y1=145,y2=278)\n", " .margin(top=2,color=(255,255,255))\n", " .crossfadein(1)\n", " .audio_fadeout(0.8)\n", " .audio_fadeout(0.8)\n", " .volumex(.7)\n", " .set_start(anna_p.start+22.2) )\n", "\n", "\n", "miriam_p = (miriam\n", " .subclip(25.8,31)\n", " .resize(height=H-piano_p.h)\n", " .volumex(0.8)\n", " .crop( x1=120,x2=120+W/3)\n", " .margin( right=2, color=3*[255])\n", " .crossfadein(0.3)\n", " .set_start(piano_p.start + 1.55)\n", " .set_end(piano_p.start + 5.65)\n", " .audio_fadeout(0.4)\n", " .fadeout(.2)\n", " .set_pos(('left','top')) )\n", " \n", " \n", "kristina_p = (kristina\n", " .subclip(33.20)\n", " .resize(height=H-piano_p.h)\n", " .volumex(0.8)\n", " .crop(x1=110,x2=110+W/3)\n", " .margin(left=2, color=3*[255])\n", " .crossfadein(0.3)\n", " .set_start(piano_p.start + 3.53)\n", " .set_end(piano_p.start + 5.65)\n", " .audio_fadeout(0.4)\n", " .fadeout(.3)\n", " .set_pos(('center','top')))\n", "\n", " \n", "irene_p = (irene\n", " .subclip(39.4,43.5)\n", " .resize( height=H-piano_p.h)\n", " .crop( x1=70,x2=70+W/3)\n", " .margin( left=2, color=3*[255])\n", " .set_start(piano_p.start + 5.80)\n", " .crossfadein(0.3)\n", " .fadeout(.3)\n", " .set_pos(('right','top')) )" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 11 }, { "cell_type": "code", "collapsed": false, "input": [ "first_verse = CompositeVideoClip([\n", " faraz_p, # not chronological, but must be under every other video\n", " anna_p,\n", " malia_p,\n", " halie_p, speed_stack_p, cooper_p,\n", " amyspants_p,\n", " shae_p,\n", " two_little_girls_p,\n", " school_choir_PS22_p,\n", " piano_p,\n", " miriam_p, kristina_p, irene_p],\n", " size=(W,H))\n", "#final.subclip(15,27).audio.to_audiofile(\"test.ogg\")\n", "#final.show(10)\n" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 12 }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Inter Rhythm" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "1 - Straight" ] }, { "cell_type": "code", "collapsed": false, "input": [ "rainbelle = VideoFileClip(\"./duet/rainbelle99.mp4\")\n", "cup_kids = VideoFileClip(\"./trio/patmartel100.mp4\")\n", "girls_complex = VideoFileClip(\"./cup_only/gimmiebeanstheband.mp4\")\n", "cantina_band = VideoFileClip(\"./choir/SMCdramaclub .mp4\")\n", "allSheKnows = VideoFileClip('./male/AllSheKnows.mp4')\n", "harvard = VideoFileClip('./cup_only/HarvardTHUD.mp4')\n", "rsnmusik = VideoFileClip(\"./cup_only/RSNmusik.mp4\")" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 13 }, { "cell_type": "code", "collapsed": false, "input": [ "rainbelle_p = (rainbelle.subclip(7.1,10.55)\n", " .reW()\n", " .crop(y2=H)\n", " .fadein(.15)\n", " .volumex(0.6) )\n", " \n", " \n", "cup_kids_p = (cup_kids.subclip(278.80,279.20)\n", " .reH()\n", " .audio_fadein(0.1) )\n", " \n", "\n", "harvard_p = (harvard.subclip(17.90,18.34)\n", " .reW()\n", " .crop(y2=H))\n", " \n", " \n", "cantina_band_p = (cantina_band.subclip(25.25,25.6)\n", " .reH()\n", " .audio_fadein(0.1) )\n", "\n", "\n", "allSheKnows_p = (allSheKnows.subclip(35.20,35.97)\n", " .reH())\n", "\n", "\n", "\n", "girls_complex_p = (girls_complex.subclip(32.00,32.78)\n", " .reH())\n", "\n", "\n", "rsnmusik_p = (rsnmusik\n", " .subclip(20.16,20.66)\n", " .volumex(0.6)\n", " .reW()\n", " .crop(y2=220) )" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 14 }, { "cell_type": "code", "collapsed": false, "input": [ "inter_rythm = concatenate([\n", " rainbelle_p,\n", " cup_kids_p,\n", " harvard_p,\n", " cantina_band_p,\n", " allSheKnows_p,\n", " girls_complex_p,\n", " rsnmusik_p])\n", "\n", "#inter_rythm.audio.preview()\n", "#inter_rythm.to_videofile('test.mp4', bitrate='6000k')" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 15 }, { "cell_type": "code", "collapsed": false, "input": [ "until_inter_rythm = concatenate(\n", " [titleScreen,\n", " first_rythm,\n", " first_verse,\n", " inter_rythm])" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 16 }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Second Verse" ] }, { "cell_type": "code", "collapsed": false, "input": [ "original_lulu = VideoFileClip(\"./duet/Lulapinga.mp4\")\n", "\n", "\n", "ally_turner = VideoFileClip(\"./girl_acapella/Ally Turner.mp4\")\n", "daiyan = VideoFileClip(\"./girl_acapella/Daiyan Trisha.mp4\")\n", "\n", "\n", "sita_lizzie = VideoFileClip(\"./duet/Sita Lizzie.mp4\")\n", "jocelyne = VideoFileClip(\"./duet/Jocelyne Van Den Meersche.mp4\")\n", "\n", "amanda = VideoFileClip(\"./girl_acapella/amandayanggg.mp4\")\n", "people_mountain = VideoFileClip(\"./choir/Camp Kulin.mp4\")\n", "duo_alaska = VideoFileClip(\"./duet/Satrina Lord.mp4\")\n", "\n", "steph = VideoFileClip(\"./girl_acapella/stephulahoops.mp4\")\n", "katrina = VideoFileClip(\"./uke_guitar_song/katrinamelody.mp4\")\n", "\n", "choir_black_cloths = VideoFileClip(\"./choir/Genesee Noelani.mp4\")" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 17 }, { "cell_type": "code", "collapsed": false, "input": [ "txt = TextClip('The original cup song',\n", " font='Ubuntu-Bold',\n", " fontsize=22)\n", "\n", "txt_original_cupsong = (txt\n", " .on_color(size=(txt.w+6, txt.h + 6),\n", " color=3*[255])\n", " .margin(1)\n", " .margin( bottom=30,right=30, opacity=0.0)\n", " .set_pos(('right','bottom'))\n", " .set_duration(1.5) )\n", "txt_original_cupsong.show()" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 18 }, { "cell_type": "code", "collapsed": false, "input": [ "original_lulu_p = (original_lulu.subclip(50,56.7)\n", " .reH()\n", " .set_pos('center')\n", " .set_end(5.6)\n", " .audio_fadeout(0.2))\n", "\n", "ally_turner_p = (ally_turner.subclip(45.5,47.5)\n", " .crop( x1 = 400, x2= 950)\n", " .resize( height=0.45*H)\n", " .margin( 2, color=3*[255])\n", " .margin(right=20, opacity=0)\n", " .set_pos(('right','center'))\n", " .set_start(1.8))\n", "\n", "wby,hby= ally_turner_p.size\n", "ally_turner_p.pos = lambda t: (W-wby-20,'center')\n", " \n", "daiyan_p = (daiyan.subclip((1,31),(1,33))\n", " .crop( x1 = 117, x2= 362)\n", " .resize(height=0.45*H)\n", " .margin(2, color=3*[255])\n", " .margin(left=20, opacity=0)\n", " .set_pos(('left','center'))\n", " .set_start(1.8) )" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 19 }, { "cell_type": "code", "collapsed": false, "input": [ "from scipy.interpolate import interp1d\n", "\n", "sita_lizzie_p= ( sita_lizzie.subclip(51.2,55.4)\n", " .reW()\n", " .audio_fadein(0.2)\n", " .crop( x1 = 38, x2=-82, y1=21,y2=358)\n", " .resize( height =0.33*H)\n", " .margin( 2, color=3*[255])\n", " .set_start(3.8)\n", " .set_end(6.7)\n", " .crossfadeout(1) )\n", "\n", "\n", "wgsv,hgsv = sita_lizzie_p.size \n", "itr_gsv = interp1d([-1,0,0.2,10],\n", " [W/2 - wgsv/2,W/2 - wgsv/2, W-wgsv-10, W-wgsv-10 ])\n", "sita_lizzie_p.pos = lambda t: (itr_gsv(t),H/2)# H-hgsv-10)\n", "\n", "\n", "jocelyne_p = (jocelyne.subclip(44.95)\n", " .crop(x1=85, x2=598, y1=27, y2=315)\n", " .resize( height=0.33*H)\n", " .margin( 2, color=3*[255])\n", " .set_start(1.8)\n", " .set_end(6.7)\n", " .crossfadeout(1)\n", " .volumex(0.4)\n", " .audio_fadein(0.2))\n", " \n", "w_joc, h_joc = jocelyne_p.size\n", "itr_joc = interp1d([-1,2,2.2,10],\n", " [W/2 - w_joc/2,W/2 - w_joc/2, 10, 10])\n", "jocelyne_p.pos = lambda t: (itr_joc(t),H/2)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 20 }, { "cell_type": "code", "collapsed": false, "input": [ "d = 2.5\n", "\n", "amanda_p= (amanda.subclip(51.0,59)\n", " .crop( x1=50, x2 = 50+W/2)\n", " .resize( width=140)\n", " .margin( 2, color=3*[255])\n", " .crossfadein(0.2)\n", " .margin( right=10,top=10,opacity=0)\n", " .set_pos(('right','top'))\n", " .volumex(1.3)\n", " .audio_fadein(2)\n", " .set_start(5.5) )\n", " \n", "\n", "people_mountain_p = ( people_mountain.subclip(49.9,51)\n", " .reW()\n", " .volumex(1.5)\n", " .set_start(6.7))\n", "\n", "\n", "duo_alaska_p = (duo_alaska.subclip(56.5,57.5)\n", " .reW()\n", " .crop(y1=-H)\n", " .volumex(1.2)\n", " .set_pos('center')\n", " .set_start(7.35))\n", "\n", "\n", "katrina_p = ( katrina.subclip(38.15+d,58)\n", " .crop( x1=138, x2=342)\n", " .reH()\n", " .margin( right=2, color=3*[255])\n", " .audio_fadein( 0.1)\n", " .set_pos('left')\n", " .set_start(amanda_p.start + d)\n", " .set_end(13.53)\n", " .audio_fadeout(.1))\n", "\n", "steph_p = (steph.subclip(52.85+d,59)\n", " .reH()\n", " .crop( x1=150, x2=150+W-katrina_p.w)\n", " .margin( left=2, color=3*[255])\n", " .volumex( 1.8)\n", " .set_pos('right')\n", " .set_start(katrina_p.start)\n", " .set_end(10.5)\n", " .audio_fadein( 0.5)\n", " .audio_fadeout( 0.5) )\n", "\n", "choir_black_cloths_p = (choir_black_cloths\n", " .subclip((1,38.1),(1,43))\n", " .reH()\n", " .crop( x2= W-katrina_p.w)\n", " .volumex(0.5)\n", " .audio_fadein(0.5)\n", " .crossfadein(0.5)\n", " .set_pos('right')\n", " .set_start(10.0)\n", " .set_end(13.6)\n", " .audio_fadeout(1))\n", "\n" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 21 }, { "cell_type": "code", "collapsed": false, "input": [ "second_verse = CompositeVideoClip([\n", " original_lulu_p,\n", " txt_original_cupsong,\n", " ally_turner_p,\n", " daiyan_p,\n", " jocelyne_p,\n", " people_mountain_p,\n", " duo_alaska_p,\n", " sita_lizzie_p,\n", " steph_p,\n", " choir_black_cloths_p,\n", " katrina_p,\n", " amanda_p ],\n", " size = (W,H))" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 22 }, { "cell_type": "code", "collapsed": false, "input": [ "second_verse_start = until_inter_rythm.duration -.14\n", "\n", "until_second_verse = CompositeVideoClip(\n", " [until_inter_rythm,\n", " second_verse.set_start(second_verse_start)])\n", "\n", "#until_second_verse.audio.subclip(start-4, start+4).preview()" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 23 }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "End" ] }, { "cell_type": "code", "collapsed": false, "input": [ "hannah_elless = VideoFileClip(\"./trio/Hannah Elless.mp4\")\n", "\n", "# First of three\n", "marj = VideoFileClip(\"./girl_acapella/Marjorie Reboul.mp4\")\n", "thomas = VideoFileClip(\"./male/Thomas Graff.mp4\")\n", "camshie = VideoFileClip(\"./trio/Camshie Tejada.mp4\")\n", "\n", "# Second of three\n", "raRaRileyStraw = VideoFileClip(\"./male/RaRaRileyStraw.mp4\")\n", "kira_mackenzie = VideoFileClip(\"./duet/Kira Pleska and Mackenzie Ziegler.mp4\")\n", "rachel = VideoFileClip(\"./duet/Rachel Nheu.mp4\")\n", "\n", "bass = VideoFileClip(\"./instrumental/Ankadiov Subran.mp4\")\n", "violin_guitar = VideoFileClip(\"./instrumental/David Wong.mp4\")\n", "flute = VideoFileClip(\"./instrumental/Laura Mew.mp4\")\n", "clarinet = VideoFileClip(\"./instrumental/clANAnett.mp4\")\n", "katie = VideoFileClip(\"./girl_acapella/Katie Floyd.mp4\")\n", "allyPaige = VideoFileClip(\"./girl_acapella/AllyyyPaige.mp4\")\n", "camryn = VideoFileClip(\"./girl_acapella/Camryn Harder.mp4\")\n", "richard = VideoFileClip(\"./male/Richard Beilfuss.mp4\")\n", "haven = VideoFileClip(\"./uke_guitar_song/Scott Slay.mp4\")\n", "\n", "lizzie = VideoFileClip(\"./ASL/lizzieejudee.mp4\")\n", "nicole = VideoFileClip(\"./uke_guitar_song/Nicole Zhang.mp4\")\n" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 24 }, { "cell_type": "code", "collapsed": false, "input": [ "M = 20\n", "B = 45\n", "\n", "hannah_elless_p = (hannah_elless.subclip(79.31,91.00)\n", " .crop(y1=40,y2=-30,x1=50, x2=-50)\n", " .resize(width=.4*W)\n", " .fadein(1)\n", " .audio_fadein(.1)\n", " .audio_fadeout(.1)\n", " .margin(1, color=3*[255])\n", " .margin(right=B, bottom=M, opacity=0)\n", " .set_pos(('right', 'bottom')))\n", "\n", "# ==================\n", "\n", "marj_p = (marj\n", " .subclip(5.9,7.4)\n", " .resize(width= .4*W)\n", " .margin(1, color=3*[255])\n", " .margin(left=B, top=M, opacity=0)\n", " .set_pos(('left', 'top')))\n", "\n", "\n", "thomas_p = ( thomas.subclip(0.6)\n", " .set_duration(marj_p.duration)\n", " .resize(width=.4*W)\n", " .crop(y2=-1, height = hannah_elless_p.h-M)\n", " .margin(1, color=3*[255])\n", " .margin(left=B, bottom=M, opacity=0)\n", " .set_pos(('left', 'bottom'))\n", " .audio_fadein(.1)\n", " .audio_fadeout(.1))\n", "\n", "\n", "\n", "camshie_p = (camshie.subclip(5.2)\n", " .set_duration(marj_p.duration)\n", " .resize(width= .4*W)\n", " #.crop(y1= -marj_p.h-50, height=marj_p.h-M)\n", " .margin(1, color=3*[255])\n", " .margin(right=B, top=M, opacity=0)\n", " .set_pos(('right', 'top')))\n", "\n", "\n", "\n", "# ==================\n", "\n", "rachel_p = (rachel.subclip(5.85,7.65)\n", " .resize(width=.4*W)\n", " .margin(1, color=3*[255])\n", " .margin(right=B, top=M, opacity=0)\n", " .set_pos(('right', 'top'))\n", " .audio_fadein(.1))\n", "\n", "kira_mackenzie_p = (kira_mackenzie.subclip(45.9, 50)\n", " .crop(x2=-50)\n", " .resize(width=.4*W)\n", " .crop(y2=-10, height = rachel_p.h-M)\n", " .margin(1, color=3*[255])\n", " .margin(left=B, top=M, opacity=0)\n", " .audio_fadein(.1)\n", " .crossfadeout(.5)\n", " .set_pos(('left', 'top'))\n", " .audio_fadeout(.1))\n", "\n", "raRaRileyStraw_p = (raRaRileyStraw.subclip(10.35)\n", " .set_duration(rachel_p.duration)\n", " .resize(width=.4*W)\n", " .crop(y1=10, height = hannah_elless_p.h-M)\n", " .margin(1, color=3*[255])\n", " .margin(left=B, bottom=M, opacity=0)\n", " .set_pos(('left', 'bottom'))\n", " .audio_fadein(.1)\n", " .audio_fadeout(.1))" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 25 }, { "cell_type": "code", "collapsed": false, "input": [ "af_start=17\n", "\n", "\n", "Hbottom = 3*H/5+2\n", "\n", "M = 20\n", "\n", "\n", "violin_guitar_p = ( violin_guitar.subclip(30.25,37)\n", " .crop(y1=100)\n", " .resize( height=Hbottom)\n", " .crop(x1=0, width=2.0*W/3)\n", " .volumex(1.5)\n", " #.subfx(lambda cl: cl.crop(x1=0, width=W/3),0,.9 )\n", " .margin( right=2, bottom=2, color=3*[255])\n", " .set_pos(('left','top'))\n", " .set_start(12.8)\n", " .audio_fadein(.1)\n", " .audio_fadeout(.5))\n", "\n", "T_bass=1.2\n", "bass_p = ( bass.subclip((1,8.95-T_bass),(1,16.5))\n", " .crop(x1=92, x2=-80)\n", " .audio_fadeout(.05)\n", " .volumex(1.0)\n", " .resize(width = 2.0*W/7)\n", " .margin( top=2, right=2, color=3*[255] )\n", " .set_pos(('left',Hbottom)) )\n", "\n", "clarinet_p = ( clarinet.subclip(25.9,31)\n", " .volumex( 0.5)\n", " .crop( x1=73, x2=-101)\n", " .resize( width=2.0*W/7-1)\n", " .margin( top=2, left=2, color=3*[255])\n", " .set_pos(('right', Hbottom))\n", " .set_start(13.8))\n", "print clarinet_p.h\n", " \n", "flute_p = ( flute.subclip(22.35)\n", " .reH()\n", " .set_duration(violin_guitar_p.duration)\n", " .audio_fadeout(1)\n", " .volumex( 1.3)\n", " .resize(width=3.0*W/7)\n", " .margin(top=2, color=3*[255])\n", " .set_pos(('center',Hbottom))\n", " .set_start(13.8))\n", " \n", " \n", "katie_p = ( katie.subclip(23.1,27)\n", " .volumex(1.6)\n", " .audio_fadein(.1)\n", " .resize(height=Hbottom)\n", " .crop( x1=10, x2=10+W/3)\n", " .margin(left=2, color=3*[255])\n", " .set_pos(('right','top')))\n", " \n", " \n", "allyPaige_p = ( allyPaige.subclip(31.35,37.8)\n", " .audio_fadeout(1)\n", " .crop(x1=70, x2=-300, y1=50)\n", " .resize( height=Hbottom)\n", " .crop( x1=75, width=W/3)\n", " .margin(left=2, right=2, color=3*[255])\n", " .set_pos((W/3,'top')))\n", "\n", "\n", "camryn_p = ( camryn.subclip(26.45,29.4)\n", " .crop(x1=300, x2=-300, y2=-100)\n", " .resize(height=Hbottom)\n", " .crop(x1=10, width=W/3)\n", " .margin(left=2, color=3*[255])\n", " .set_pos(('right', 'top')))\n", "\n", "\n", "richard_p = (richard.subclip((1,13.05),(1,16.5))\n", " .audio_fadein(.1)\n", " .audio_fadeout(.5)\n", " .crop(y1=45,x1=70)\n", " .resize(width = clarinet_p.w)\n", " .margin(top=2, left=2, color=3*[255])\n", " .set_pos(('right',Hbottom))\n", " .volumex(2.5) )" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "160\n" ] } ], "prompt_number": 26 }, { "cell_type": "code", "collapsed": false, "input": [ "haven_p = ( haven.subclip((1,54.65))\n", " .reH()\n", " .volumex(.5)\n", " .audio_fadein(.8)\n", " .resize(width=0.4*W)\n", " .margin(1, color=3*[255])\n", " .margin(right=40, opacity=0)\n", " .set_pos(('right','center')) )\n", "\n", "lizzie_p = (lizzie.subclip((1,29.3),(1,34.5))\n", " .set_audio(None)\n", " .resize(width=.4*W)\n", " .margin(1, color=3*[255])\n", " .margin(left=40, opacity=0)\n", " .set_pos(('left','center'))\n", " .fadein(1)\n", " .fadeout(.5))\n", "\n", "nicole_p = (nicole.subclip(36.9,-.1)\n", " .crop(y1=50)\n", " .resize(width=.4*W)\n", " .volumex(2)\n", " .audio_fadein(.2)\n", " .fadein(.5)\n", " .margin(1, color=3*[255])\n", " .margin(left=40, opacity=0)\n", " .fadeout(.1)\n", " .set_pos(('left','center')))" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 27 }, { "cell_type": "code", "collapsed": false, "input": [ "he_start = second_verse_start + 10.45\n", "d1 = 3.5 # clap clap 1\n", "d2 = 6.9 # clap clap 2\n", "\n", "\n", "d = he_start+ 10.28 # start_orchestra\n", "dstop = d+7.5 # stop_orchestra\n", "\n", "until_last_chorus = CompositeVideoClip([\n", "\n", " until_second_verse,\n", "\n", " hannah_elless_p.set_start(he_start-.45),\n", "\n", " marj_p.set_start(he_start+d1),\n", " camshie_p.set_start(he_start+d1),\n", " thomas_p.set_start(he_start+d1),\n", "\n", " raRaRileyStraw_p.set_start(he_start+d2),\n", " rachel_p.set_start(he_start+d2),\n", "\n", " violin_guitar_p.set_start(d).set_end(dstop),\n", " kira_mackenzie_p.set_start(he_start+d2),\n", "\n", " flute_p.set_start(d).set_end(dstop),\n", " clarinet_p.set_start(d),\n", " katie_p.set_start(d),\n", " bass_p.set_start(d-T_bass).set_end(dstop),\n", " allyPaige_p.set_start(d+1.5).set_end(dstop),\n", " richard_p.set_start(d+4.0).set_end(dstop),\n", "\n", " camryn_p.set_start(d+4.0).set_end(dstop),\n", " haven_p.set_start(d+5.75),\n", " lizzie_p.set_start(dstop+.5),\n", " nicole_p.set_start(d+13.8)\n", " ])" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 28 }, { "cell_type": "code", "collapsed": false, "input": [ "#until_last_chorus.to_videofile('test_ulc.mp4',fps=5)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 29 }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Credits" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import re\n", "import os\n", "from moviepy.editor import *\n", "\n", "def chunks(l, n):\n", " \"\"\"\n", " Yield successive n-sized chunks from l.\n", " \"\"\"\n", " for i in range(0, len(l), n):\n", " yield l[i:i+n]\n", "\n", "andrew_foy = VideoFileClip(\"./instrumental/Andrew Foy.mp4\")\n", "jenni_saslove = VideoFileClip(\"./girl_acapella/Jenni Saslove.mp4\")\n", "brie_monetti = VideoFileClip(\"./uke_guitar_song/Brie Monetti.mp4\")\n", "jenna_lynn = VideoFileClip(\"./uke_guitar_song/Jenna Lynn.mp4\")\n", "tiffany = VideoFileClip(\"./uke_guitar_song/Tiffany Cicio.mp4\")" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 30 }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "# We open THIS notebook !\n", "with open('./CupSongsCovers.ipynb','r') as f:\n", " lines = f.readlines()\n", "\n", "files = [re.search(\"VideoFileClip\\((.*)\\)\", l) for l in lines]\n", "files = [f.groups()[0][1:-1] for f in files if f is not None]\n", "names = [os.path.splitext(os.path.basename(f))[0] for f in files]\n", "print ', '.join(names)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "xkaraxmusicx, DrewMannMusic, taliajoy18, hoorahjencar, hoosierfamily, salvadorzepeda68, NicoleKim, Anna Burden, MaliaRogersMusic, Halie Ranee, eveecooper, theaterobsession101, Faraz Sabir, amyspants, Miriam Carone, Kristina G, Irene Poon, MuggleSam, PS22 Chorus, Jasper Tan, McKenna Shae, rainbelle99, patmartel100, gimmiebeanstheband, SMCdramaclub , AllSheKnows, HarvardTHUD, RSNmusik, Lulapinga, Ally Turner, Daiyan Trisha, Sita Lizzie, Jocelyne Van Den Meersche, amandayanggg, Camp Kulin, Satrina Lord, stephulahoops, katrinamelody, Genesee Noelani, Hannah Elless, Marjorie Reboul, Thomas Graff, Camshie Tejada, RaRaRileyStraw, Kira Pleska and Mackenzie Ziegler, Rachel Nheu, Ankadiov Subran, David Wong, Laura Mew, clANAnett, Katie Floyd, AllyyyPaige, Camryn Harder, Richard Beilfuss, Scott Slay, lizzieejudee, Nicole Zhang, Andrew Foy, Jenni Saslove, Brie Monetti, Jenna Lynn, Tiffany Cicio\n" ] } ], "prompt_number": 31 }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "D=1.72\n", "\n", "txt_end = (TextClip(\"Original Cup Song written by\\n\"\n", " \"Lulu and the Lampshades\",\n", " fontsize=30, interline=15,\n", " bg_color='black',\n", " font=\"Ubuntu-Regular\",\n", " size=(W,H), color = 'white')\n", " .set_pos(('center', 'center'))\n", " .set_duration(3)\n", " .fadein(1)\n", " .fadeout(1)\n", " .fx(vfx.freeze_at_start, 1))\n", "\n", "txt0 = (TextClip(\"Youtubers by order\\nof appearance:\",\n", " fontsize=30, interline=15,\n", " bg_color='black',\n", " font=\"Ubuntu-Regular\",\n", " size=(W,H), color = 'white')\n", " .set_duration(3)\n", " .fadein(1)\n", " .fadeout(1)\n", " .fx(vfx.freeze_at_start, 1))\n", "\n", "txts = [TextClip(\"\\n\".join(nn),\n", " fontsize=30,\n", " font=\"Ubuntu-Regular\",\n", " color = 'white', interline=9)\n", " .set_pos(('center', 'center'))\n", " .fadein(.3)\n", " .set_start(D*(i))\n", " .set_duration(D)\n", " .fadeout(.3)\n", " for i,nn in enumerate(chunks(names,7))]\n" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 32 }, { "cell_type": "code", "collapsed": false, "input": [ "W2 = 2*W/7\n", "end_time=19\n", "andrew_foy_p = (andrew_foy\n", " .resize(width=W2)\n", " .margin(1, color=3*[255])\n", " .margin(left=10, bottom=10, opacity=0)\n", " .set_pos(('left','bottom'))\n", " .subclip(23)\n", " .volumex(.6)\n", " .audio_fadein(1)\n", " .audio_fadeout(1))\n", "\n", "brie_monetti_p = (brie_monetti\n", " .crop(y2=300, x2=-150)\n", " .resize(width=W2)\n", " .margin(1, color=3*[255])\n", " .margin(right=10, top=10, opacity=0)\n", " .set_pos(('right','top'))\n", " .subclip(47, 52)\n", " .audio_fadein(.1))\n", " \n", "jenni_saslove_p = (jenni_saslove\n", " .resize(width=W2)\n", " .margin(1, color=3*[255])\n", " .margin(left=10, top=10, opacity=0)\n", " .set_pos(('left','top'))\n", " .subclip(24.5, 27.3)\n", " .audio_fadein(.3))\n", "\n", "jenna_lynn_p = (jenna_lynn.subclip(30.45, 34.5)\n", " .resize(width=W2)\n", " .margin(1, color=3*[255])\n", " .margin(right=10, bottom=10, opacity=0)\n", " .set_pos(('right','bottom'))\n", " .audio_fadein(.1))\n", "\n", "tiffany_p = (tiffany.subclip(40.5)\n", " .resize(width=W2)\n", " .margin(1, color=3*[255])\n", " .margin(left=10, top=10, opacity=0)\n", " .set_pos(('left','top'))\n", " .audio_fadein(.2)\n", " .volumex(.5)\n", " .audio_fadein(.5)\n", " .audio_fadeout(1))\n", "\n", "\n", "af_start = 0\n", "bm_start = af_start + 1\n", "js_start = af_start + 5.3\n", "mar_start = af_start + 3\n", "kf_start = af_start + 8.8\n", "tiff_start = af_start + 12.6\n", "jl_start = af_start + 15.85\n", "scott_start = af_start + 23.5\n", "\n", "\n", "\n", "credits = (CompositeVideoClip(txts+[\n", " andrew_foy_p.set_start(af_start),\n", " brie_monetti_p.set_start(bm_start),\n", " jenni_saslove_p.set_start(js_start),\n", " jenna_lynn_p.set_start(kf_start),\n", " tiffany_p.set_start(tiff_start)\n", " ],\n", " size= (W,H))\n", " .set_duration(17+af_start)\n", " .fadein(1)\n", " .fadeout(1)\n", " .audio_fadeout(1)\n", " .audio_fadeout(1))" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 33 }, { "cell_type": "code", "collapsed": false, "input": [ "len(names)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 34, "text": [ "62" ] } ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "\n", "# made wit moviepy\n", "\n", "mwm = ( ImageClip('logo_white.png')\n", " .resize(width=0.6*W)\n", " .on_color(size= [W,H], pos=('center',H/5)))\n", "\n", "mwm_audio = (AudioFileClip(\"./cupspiano.wav\")\n", " .subclip(.2)\n", " .audio_fadein(.5)\n", " .audio_fadeout(.5))\n", "\n", "grenoble = (TextClip(\"Grenoble, 2014\",fontsize=25,\n", " font=\"Amiri-Regular\", color='gray')\n", " .margin(right=20, bottom=10, opacity=0)\n", " .set_pos(('right', 'bottom')))\n", "\n", "mwm_grenoble = (CompositeVideoClip([mwm, grenoble])\n", " .set_audio(mwm_audio)\n", " .set_duration(mwm_audio.duration)\n", " .fadein(1).fadeout(1))\n", "\n", "\n", "credits_and_end = concatenate([txt_end, txt0,\n", " credits,\n", " mwm_grenoble])\n", "\n", "\n", "#credits_and_end.to_videofile('testend.mp4', fps=25)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "until_end = concatenate([until_last_chorus,\n", " credits_and_end])\n", "\n", "until_end.to_videofile(\"Cup_Song_Covers_Mix.mp4\",\n", " fps=25, bitrate=\"10000k\",\n", " audio_bitrate='500k')" ], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }