title: How do you use masks from pngs with moviepy?
body: <p>I am trying to use masks with moviepy.</p>
  
  <p>I would like to use an image file like this (<a href="http://imgur.com/1IGHflk" rel="nofollow">http://imgur.com/1IGHflk</a>) and overlay it as a mask on top of a video, so that only the black part of the image is transparent in the video. </p>
  
  <p>I am able to get this to work when I make the mask image exactly the same size as the video, but I can't figure out how to make it work with a mask image which is smaller. I would like to take the small mask image given, and position it onto the video (further I would actually like to take this mask image and put it onto a video as a mask in few different locations at once).</p>
  
  <p>I've included the code below where I tried to do this as well as the error I get. Any help is appreciated (or just a link to a simple example showing how to use moviepy masks). Thank you!</p>
  
  <pre><code>from moviepy.editor import VideoFileClip, concatenate_videoclips, ImageClip, vfx, AudioFileClip, \
  concatenate_audioclips, CompositeAudioClip, ColorClip, CompositeVideoClip, VideoClip
  
  import random
  
  
  if __name__ == '__main__':
  
      DEFAULT_CLIP_HEIGHT = 720
      DEFAULT_CLIP_WIDTH = 1280
  
      color_clip = ColorClip(size=(DEFAULT_CLIP_WIDTH, DEFAULT_CLIP_HEIGHT), col=((0, 0, 255)))
      color_clip = color_clip.set_duration(15)
      color_clip = color_clip.set_fps(DEFAULT_FPS)
  
      color_clip2 = ColorClip(size=(DEFAULT_CLIP_WIDTH, DEFAULT_CLIP_HEIGHT), col=((255, 0, 0)))
      color_clip2 = color_clip2.set_duration(15)
      color_clip2 = color_clip2.set_fps(DEFAULT_FPS)
  
      rounded_border_path = os.path.join(PROJECT_PATH, 'black_on_white_small.png')
      mask_clip = ImageClip(rounded_border_path)
      mask_clip = mask_clip.set_duration(10)
      mask_clip = mask_clip.set_fps(DEFAULT_FPS)
      mask_clip = mask_clip.set_position(('center', 'center'))
  
      comp_clip = CompositeVideoClip([mask_clip], bg_color=(255, 255, 255),
                                 size=(DEFAULT_CLIP_WIDTH, DEFAULT_CLIP_HEIGHT), ismask=True)
  
       color_clip.mask = comp_clip
  
       comp_clip = CompositeVideoClip([color_clip2, color_clip], size=(DEFAULT_CLIP_WIDTH, DEFAULT_CLIP_HEIGHT))
  
       o_path = os.path.join(PROJECT_PATH, 'comp_color.mp4')
       comp_clip.write_videofile(o_path, fps=DEFAULT_FPS, codec='libx264')
  </code></pre>
  
  <p>yields error:
  <code>File "/Users/maxfowler/Dropbox/desktop/cs/upwork_montage/custom_moviepy/moviepy/video/compositing/CompositeVideoClip.py", line 110, in make_frame
      f = c.blit_on(f, t)
    File "/Users/maxfowler/Dropbox/desktop/cs/upwork_montage/custom_moviepy/moviepy/video/VideoClip.py", line 570, in blit_on
      return blit(img, picture, pos, mask=mask, ismask=self.ismask)
    File "/Users/maxfowler/Dropbox/desktop/cs/upwork_montage/custom_moviepy/moviepy/video/tools/drawing.py", line 43, in blit
      1.0 * mask * blitted + (1.0 - mask) * blit_region)
  ValueError: operands could not be broadcast together with shapes (720,1280,9) (720,1280,3)</code></p>