5

This code works perfectly from my local machine.

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)

I would like to run it from AWS

Lambda code

import boto3

import subprocess

s3 = boto3.client('s3')


def lambda_handler(event, context):

    ep1PNG = s3.get_object(Bucket='my-buc',Key='ep1.PNG')
    ep1MP3 = s3.get_object(Bucket='my-buc',Key='ep1.mp3')

    p = subprocess.call(
    '/opt/ffmpeg/ffmpeg -r 1 -loop 1 -i ep1PNG -i ep1MP3 -acodec copy -r 1 -shortest -vf scale=1280:720 /tmp/ep1.flv', shell=True)


    # TODO implement
    return {
        'statusCode': 200,

    }

Questions

Are these correct inside subprocess.call() ?

/opt/ffmpeg/ffmpeg  #<-----Is this correct ?
ep1PNG           #<-----Is this correct ?
ep1MP3          #<-----Is this correct ?
/tmp/ep1.flv   #<----- Not Sending Output to S3 Bucket 

Please comment if I'm heading in the right direction been trying this for about a week now

ffmpeg is uploaded as a layer

Jay
  • 185
  • 15
  • 1
    Possible duplicate with https://stackoverflow.com/a/48945900/2450936 – howie May 09 '19 at 22:55
  • 1
    @howie the question you taged has nothing to do with ffmpeg... – Jay May 09 '19 at 22:58
  • Ok , I think you question is can you save tmp file in lamda and sent to s3 ? – howie May 09 '19 at 23:04
  • @Jay your question in its core also has nothing to do with ffmper; whehter you call `ffmpeg` or any other program that takes files and generates files makes no difference to your problem at all. So, it's pretty much a duplicate. – Marcus Müller May 11 '19 at 19:19
  • Possible duplicate of [How could I use aws lambda to write file to s3 (python)?](https://stackoverflow.com/questions/48945389/how-could-i-use-aws-lambda-to-write-file-to-s3-python) – Marcus Müller May 11 '19 at 19:19
  • Did you find out why this wasn't working? I'm in a similar boat. with ffmpeg running on aws lambda layers. Running ls in my current directory doesn't show an opt folder and the opt ldirectory in the parent level is empty. No, it's not a duplicate of any of the links above since the question is asking about ffmpeg specifically in aws lambda layers. – Mayowa Daniel Aug 23 '20 at 15:04

1 Answers1

-2

A nodejs lambda solution for running ffmpeg can be found here

https://github.com/binoculars/aws-lambda-ffmpeg

This may be a ready made solution for you or offer some insight in how to tackle your task.

al76
  • 754
  • 6
  • 13
  • 2
    Link-only answers are generally frowned upon. Please give a conclusion of the site you link to. Explain why it's especially applicable to OP's problem. – Marcus Müller May 11 '19 at 19:17
  • That's not what I had in mind, @al76. Your answer must stand alone, even if that external repo goes down. Explain what it does, at least shortly, in your answer. – Marcus Müller May 11 '19 at 20:49
  • @MarcusMüller hey I think we had a discussion about mixers on the ee forum you're all over the place – Jay May 12 '19 at 00:39