views:

37

answers:

2

My project will require users to upload uncompressed WAV audio files and once they do, the server will need to encode it in MP3 to serve it on the site. I'm using Django for this project and it'll be hosted on a Linux VPS (from Linode). Due to space and bandwidth, I want to use Amazon S3.

I'm not an expert at this stuff, this project will be covering many new things for me. But any guidance on this would be a great thing for me.

I will most probably be using the django-storages app to talk with Amazon S3. But I'm not sure at what point I would run the server command for FFmpeg to do it's conversions. If a user is uploading an audio file, django-storages will place it on Amazon S3. But then, where and how, do I get FFmpeg to run it's commandline on that file just uploaded to do the encoding to MP3 and then my website to serve and use that MP3 (which should at that point also be on Amazon S3)?

I'm a little confused on how to go about it. Like I say, I'm not an expert! Could anyone guide me on this?

A: 

May be don't use django-storage for such files, You can convert the audio to a temp mp3 file on server (Linux VPS) and using boto or command line S3 tool or some other way upload mp3 to S3.

Anurag Uniyal
+1  A: 

You might consider writing a custom storage backend. This should be pluggable into django-storages, but I've never used the app and can't say for sure. You can find some guidance on writing custom storage backends here: http://docs.djangoproject.com/en/dev/howto/custom-file-storage/

In your backend, you can use Python's subprocess command to run ffmgpeg to handle the mp3 conversion: http://docs.python.org/library/subprocess.html#subprocess.call

Chris Lawlor
Thank you... I think that using Boto, with a custom backend for my app, and using the subprocess command is exactly what I need to do. Thanks!
littlejim84