Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS Lambda - Moviepy Error - #638

Closed
ghoshtapo opened this issue Aug 28, 2017 · 9 comments
Closed

AWS Lambda - Moviepy Error - #638

ghoshtapo opened this issue Aug 28, 2017 · 9 comments
Labels
lib-misc Issues pertaining to misc. 3rd-party libraries.

Comments

@ghoshtapo
Copy link

ghoshtapo commented Aug 28, 2017

I am trying to add text to a GIF in an AWS Lambda Function. I am stuck with this for the last couple of days. if you could help me that would be great. FYI - have ffmpeg executable bundled with the lambda.

Here is my relevant code

def creategif(text, gif,
               hor_align='center', ver_align='top',
               text_height=20, text_width=60):

       .....
...

        txt_clip = txt_clip.set_position((hor_align, ver_align)).set_duration(clip.duration)

        # Overlay the text clip on the first video clip
        video = CompositeVideoClip([clip, txt_clip])

        # Write the result to a file

        video.write_gif("/tmp/pr1n.gif")

IOError: MoviePy Error: creation of None failed because of the following error:

convert: not authorized `@/tmp/tmpRGnjui.txt' @ error/property.c/InterpretImageProperties/2981.
.

.This error can be due to the fact that ImageMagick is not installed on your computer, or (for Windows users) that you didn't specify the path to the ImageMagick binary in file conf.py, or.that the path you specified is incorrect

@Zulko
Copy link
Owner

Zulko commented Aug 28, 2017

Did you install imagemagick ?

@ghoshtapo
Copy link
Author

I did not. Doesn't AWS lambda come pre-installed with imagemagick? If not, then which ImageMagick deps do I have to add to the lambda? I am building the lambda from an Amazon Linux Ec2

@Zulko
Copy link
Owner

Zulko commented Aug 28, 2017

Can't help with that sorry.

@ghoshtapo
Copy link
Author

No worries. I got it to work. thanks

@justswim
Copy link
Contributor

justswim commented Sep 28, 2017

@ghoshtapo Just curious, how did you get it to work? I'm running into the same error. Thanks for your help!

@ghoshtapo
Copy link
Author

I ended up firing up a Linux AMI ec2 and adding magick and ffmpeg and the libs(lib64) in the deployable:

[root@ip- giftest]# ll
total 90428
-rwxr-xr-x 1 1000 1000 46387776 Aug 16 09:39 ffmpeg
-rw-r--r-- 1 root root 4525 Aug 28 19:39 giftest.py
-rw-r--r-- 1 root root 673 Aug 25 16:22 giphy.py
drwxr-xr-x 2 root root 4096 Aug 25 17:02 lib
-rwxr-xr-x 1 root root 6554673 Aug 28 19:20 magick
-rwxr-xr-x 1 root root 650 Aug 28 19:29 redeploy.sh
drwxr-xr-x 7 root root 4096 Aug 25 16:38 tenv

My redepoy.sh looks like this

cd tenv/lib/python2.7/site-packages/
aws lambda delete-function --function-name giftest
rm -f ../../../../giftest.zip
zip -r9 ../../../../giftest.zip *
cd /root/gifbot/tenv/lib64/python2.7/site-packages/
zip -r9 ../../../../giftest.zip *
cd ../../../../
zip -g giftest.zip ffmpeg
zip -g giftest.zip magick
zip -g giftest.zip giftest.py
zip -g giftest.zip giphy.py
aws lambda create-function --region us-east-1 --function-name giftest --zip-file fileb://giftest.zip --role "arn:aws:iam::2222222222:role/test-role" --handler giftest.lambda_handler --runtime "python2.7"  --timeout 120 --memory-size 1024

@justswim
Copy link
Contributor

@ghoshtapo Thanks for your help. Did you also add the convert binary for ImageMagick, or was magick enough? I got ffmpeg to work but I'm still running into problems getting ImageMagick to work on my lambda.

Getting this error specifically:

convert: not authorized `@/tmp/tmpgmdp05z6.txt' @ error/property.c/InterpretImageProperties/2981.

This error can be due to the fact that ImageMagick is not installed on your computer, or (for Windows users) that you didn't specify the path to the ImageMagick binary in file conf.py, or.that the path you specified is incorrect

@keikoro keikoro added the lib-misc Issues pertaining to misc. 3rd-party libraries. label Nov 25, 2017
@sandeepbalagopal09
Copy link

I ended up firing up a Linux AMI ec2 and adding magick and ffmpeg and the libs(lib64) in the deployable:

[root@ip- giftest]# ll
total 90428
-rwxr-xr-x 1 1000 1000 46387776 Aug 16 09:39 ffmpeg
-rw-r--r-- 1 root root 4525 Aug 28 19:39 giftest.py
-rw-r--r-- 1 root root 673 Aug 25 16:22 giphy.py
drwxr-xr-x 2 root root 4096 Aug 25 17:02 lib
-rwxr-xr-x 1 root root 6554673 Aug 28 19:20 magick
-rwxr-xr-x 1 root root 650 Aug 28 19:29 redeploy.sh
drwxr-xr-x 7 root root 4096 Aug 25 16:38 tenv

My redepoy.sh looks like this

cd tenv/lib/python2.7/site-packages/
aws lambda delete-function --function-name giftest
rm -f ../../../../giftest.zip
zip -r9 ../../../../giftest.zip *
cd /root/gifbot/tenv/lib64/python2.7/site-packages/
zip -r9 ../../../../giftest.zip *
cd ../../../../
zip -g giftest.zip ffmpeg
zip -g giftest.zip magick
zip -g giftest.zip giftest.py
zip -g giftest.zip giphy.py
aws lambda create-function --region us-east-1 --function-name giftest --zip-file fileb://giftest.zip --role "arn:aws:iam::2222222222:role/test-role" --handler giftest.lambda_handler --runtime "python2.7"  --timeout 120 --memory-size 1024

Where did you download the magick library ? Do we need have to just download, exact and add to zip ? No need for installing ?

@tburrows13
Copy link
Collaborator

I think that this is what you are looking for: #401 (comment)

Otherwise, feel free to reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib-misc Issues pertaining to misc. 3rd-party libraries.
Projects
None yet
Development

No branches or pull requests

6 participants