0

For starters, I am running the Django service on AWS Elastic Beanstalk and I am trying to trim a video's length with moviepy's ffmpeg_extract_subclip method then save it into the linked S3 bucket.

     media_storage = S3Boto3Storage()

     #used for targetname
     subclip_url = "temp/" + str(asset.id) + "-" + str(i) + ".mp4"

     #get url of file 
     asset_url = media_storage.url(str(asset.asset_url))
     self.create_clip(asset_url, subclip_url)
     if not media_storage.exists(subclip_url):
         curr_clip = open(settings.MEDIA_ROOT + "/" + subclip_url)
         object_file = files.File(curr_clip)
         media_storage.save(subclip_url,object_file)

I split the ffmpeg_extract_subclip into another method below

    def create_clip(self, asset_url, subclip_url):
        url = settings.MEDIA_ROOT + "/" + subclip_url
        ffmpeg_extract_subclip(asset_url, 0, 5, targetname=url)

My idea is to save the edited clip into the local directory, then open it and then send it to the S3 bucket. However, in this case, I have permission denied in EB when ffmpeg_extract_subclip attempts to save the file in the EB system (Which makes sense). Should I attempt to find a solution to override these permissions or is there perhaps a better way to edit a clip and send it to S3 through EB? Most of the methods I have found online requires Python to save the edited file to an output file.

P.S. Sorry If I am not clear enough in my question, I am still new at posting to these boards

  • Have a look at the source code for `ffmpeg_extract_subclip`. It is a very simple wrapper around ffmpeg. (ie there's very little code there). – Tom Burrows May 23 '20 at 09:49
  • 1
    So something like https://stackoverflow.com/questions/31530772/local-ffmpeg-output-to-s3-bucket might help? – Tom Burrows May 23 '20 at 09:53
  • For the time being, I am just overriding the EB permissions to save the file. I'll definitely use this method when I go back to it. Thanks – John Marshall May 23 '20 at 10:51

0 Answers0