开发者

Using FFmpeg to encode audio once uploaded, using Django, VPS (Linux) and Amazon S3

开发者 https://www.devze.com 2023-01-07 13:33 出处:网络
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 b

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 开发者_C百科on this?


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消