title: Cannot resize videos using moviepy on aws lambda
body: <p>I partially created an aws lambda function that utilize moviepy to concatenate images and videos in a single video file.</p>
  
  <p>For example, I have “img1.jpeg”, “img2.jpeg”, “video1.mp4” and “video2.mp4”. After processing the above files the final clip (“mp4” file) will be a single mp4 file of: “img1.jpeg + video1.mp4 + img2.jpeg + video2.mp4”. The fresulted clip resolution is 640x480. </p>
  
  <p>So I resize the videos and the images (moviepy.video.fx.all.resize - resize images after converting to videos) in the case that they are greater than the aforementioned resolution. If the media files are in the above size, I move to the concatenation process.</p>
  
  <p>When the media files are 640x480 all the process goes fine. The issue is when the media are larger than 640x480 I get an error:</p>
  
  <pre><code>[Errno 32] Broken pipe
  
  MoviePy error: FFMPEG encountered the following error while writing file 1_img_transTEMP_MPY_wvf_snd.mp3:
  
  1_img_transTEMP_MPY_wvf_snd.mp3: Permission denied
  
  
  The audio export failed, possily because the bitrate you specified was two high or too low for the video codec.: IOError
  Traceback (most recent call last):
  File "/var/task/media_merge.py", line 70, in handler
  s.do_merge()
  File "/var/task/mediamerge/stitch_video_and_images.py", line 320, in do_merge
  self.convert_crop_media()
  File "/var/task/mediamerge/stitch_video_and_images.py", line 310, in convert_crop_media
  res_path = resize.resize_media()
  File "/var/task/mediamerge/stitch_video_and_images.py", line 229, in resize_media
  self.final_media_file, verbose=False)
  File "&lt;decorator-gen-51&gt;", line 2, in write_videofile
  File "/var/task/moviepy/decorators.py", line 54, in requires_duration
  return f(clip, *a, **k)
  File "&lt;decorator-gen-50&gt;", line 2, in write_videofile
  File "/var/task/moviepy/decorators.py", line 137, in use_clip_fps_by_default
  return f(clip, *new_a, **new_kw)
  File "&lt;decorator-gen-49&gt;", line 2, in write_videofile
  File "/var/task/moviepy/decorators.py", line 22, in convert_masks_to_RGB
  return f(clip, *a, **k)
  File "/var/task/moviepy/video/VideoClip.py", line 331, in write_videofile
  verbose=verbose)
  File "&lt;decorator-gen-73&gt;", line 2, in write_audiofile
  File "/var/task/moviepy/decorators.py", line 54, in requires_duration
  return f(clip, *a, **k)
  File "/var/task/moviepy/audio/AudioClip.py", line 204, in write_audiofile
  verbose=verbose, ffmpeg_params=ffmpeg_params)
  File "&lt;decorator-gen-70&gt;", line 2, in ffmpeg_audiowrite
  File "/var/task/moviepy/decorators.py", line 54, in requires_duration
  return f(clip, *a, **k)
  File "/var/task/moviepy/audio/io/ffmpeg_audiowriter.py", line 162, in ffmpeg_audiowrite
  writer.write_frames(chunk)
  File "/var/task/moviepy/audio/io/ffmpeg_audiowriter.py", line 122, in write_frames
  raise IOError(error)
  IOError: [Errno 32] Broken pipe
  
  MoviePy error: FFMPEG encountered the following error while writing file 1_img_transTEMP_MPY_wvf_snd.mp3:
  
  1_img_transTEMP_MPY_wvf_snd.mp3: Permission denied
  
  
  The audio export failed, possily because the bitrate you specified was two high or too low for the video codec.
  </code></pre>
  
  <p>The above is from aws lambda logs. The funny thing is, that when I ran it locally it works.</p>
  
  <p>Has anyone ever faced a similar issue or is anyone able to give me some pointers on how to tackle this problem?</p>