Reputation: 185
This code works perfectly on my local machine but I would like to move it to AWS Lambda
I have already uploaded ffmpeg as a binary dependency to the function layer
import subprocess
p = subprocess.call(
'ffmpeg -r 1 -loop 1 -i "./ep1.png" -i "./ep1.mp3" -acodec copy -r 1 -shortest -vf scale=1280:720 ep1.flv', shell=True)
Question is How do I replace
"./ep1.png"
and
"./ep1.mp3"
as an understandable path for the ffmpeg command
This is documentation I found from boto3 but I'm not sure how to implement it
s3 = boto3.client('s3')
s3.download_file('BUCKET_NAME', 'OBJECT_NAME', 'FILE_NAME')
Let me know if I'm heading in the right direction, after this step I would use boto3 to upload ep1.flv to an output S3 bucket
Upvotes: 0
Views: 487
Reputation: 269490
AWS Lambda functions can store data in the /tmp/
directory.
So, you could use:
s3.download_file('my-bucket', 'ep1.mp3', '/tmp/ep1.mp3')
s3.download_file('my-bucket', 'ep1.png', '/tmp/ep1.png')
p = subprocess.call(
'ffmpeg -r 1 -loop 1 -i "/tmp/ep1.png" -i "/tmp/ep1.mp3" -acodec copy -r 1 -shortest -vf scale=1280:720 /tmp/ep1.flv', shell=True)
Also, make sure you delete the files in /tmp/
before your function exits because the container might be reused and there is only 500MB of storage provided.
Upvotes: 1