AWS Lambda with moviepy
I recently found this neat library for working with videos in python moviepy. It provides a super simple way of installing ffmpeg and acts as a python wrapper to perform some nifty audio/video processing.
If you can't be bothered to follow all the steps download my moviepy.zip file and jump straight to adding your code (step 6). Just remember if you have other python dependencies you will also need to add those to the zip.
After a lot of googling here are the steps to follow to get moviepy up and running in your AWS Lambda project:
spin up an EC2 instance using
Amazon Linux AMI 2018.03.0 (HVM), SSD Volume Type
ssh onto your box and install Python 3.6 and virtualenv using the following steps:
sudo yum install -y gcc zlib zlib-devel openssl openssl-devel
tar -xzvf Python-3.6.1.tgz
cd Python-3.6.1 && ./configure && make
sudo make install
sudo /usr/local/bin/pip3 install virtualenv
choose the virtual environment that was installed via pip3 /usr/local/bin/virtualenv
install libraries in the virtual environment
pip install moviepy
pip install requests
add the contents of lib and lib64 site-packages to your .zip file.
Note that the following steps assume you used Python runtime version 3.6. If you used version 2.7 you will need to update accordingly.
zip -r9 ~/moviepy.zip .
Add your python code to the .zip file
zip -g moviepy.zip lambda_function.py
IMAGEIO_USERDIRenvironment variable to
/tmpon your lambda to allow image.io write it's necessary files.