beetbox / audioread

cross-library (GStreamer + Core Audio + MAD + FFmpeg) audio decoding for Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implementation into AWS, no backend for MP3

Nashluffy opened this issue · comments

Trying to deploy this package to an AWS Lambda function with some problems. Works great with AIF, and probably some other file types, but really looking for MP3 support.

So, I've created a Python file called importFile, that's heavily based on the example provided. It works for all audio file types as expected, locally. redactedImportFile.txt. The general idea being, pull a file from a cloud location, convert it, and push it to a different cloud location.

Now, when I install all packages into a deployment folder using "pip install --target ." , zip them, and deploy to Lambda, something doesn't work. It's pretty hard to debug the no backend issue, and I'm not sure if I'm missing something obvious here.

What I've tried:

  • Creating virtual environment, installing dependencies, and deploying
  • Installing dependencies to folder, zipping with importFile.py, and deploying
  • Comparing pip freeze on my local machine to the packages I've installed in the virtual environment/deployment folder

What's worked

  • Nothing

Dependencies I have installed for deployment

  • wave
  • pygobject
  • gstreamer
  • audioread
  • boto3
  • ffmpeg

I have ffmpeg and gstreamer installed with hopes that one of the two backends would work.

Here is an output of my CloudWatch logs, the 18:36 time-stamp being an AIF file uploaded and the 18:42 time-stamp being an MP3 file uploaded.

image

I've read through some of the other no backend issues but none similar to this. If this isn't an audioread issue, then I do apologize. Thanks for your time

Interesting! I don't know much about the Lambda environment, so it's hard to say what exactly is going wrong. I notice this in your script:

    except audioread.DecodeError:
        print("File could not be decoded.", file=sys.stderr)
        sys.exit(1)

And of course that's being printed to the log. If you were to not catch the exception, and instead let it propagate to the top level, it would print a stack trace that could indicate what's going wrong. Without that stack trace, however, it's impossible to tell what error is being raised and from where.

stacktrace

Attached is what I get printing out the stack traceback.

Interesting. It's hard to say why we're not able to detect FFmpeg installed on the system. If you're interested in digging farther, you could try explicitly importing audioread.ffdec and instantiating the FFmpegAudioFile class within to try forcing that specific backend, which might give you a more specific error.

It's saying it's not installed, which is really weird. I wonder what backend it is using for AIFF? Any ideas besides calling each backend explicitly and testing?
stacktrace

The backend says that when it tries running an ffmpeg command line and the OS says "file not found," i.e., there is no executable called ffmpeg on the system. Maybe it's not installed in a way that's available on your $PATH?

Oh also, to answer your earlier question: to decode AIFF, there's a built-in Python module it uses:
https://docs.python.org/3.7/library/aifc.html

Gotcha! I did a little more digging and you're exactly right, I'm missing some C++ libraries. I've managed to get everything in one location (a portable ffmpeg, if you will), but it's too large for AWS Lambda. Anyways, not an Audioread problem, so I'll close.

Thanks so much for your time and help. And for audioread!

Sorry, I guess I should include my solution for anyone who may be trying to do the same. I ended up using a serverless deployment of ffmpeg.