1

几周以来,我一直试图弄清楚这一点。我之前问过一个类似的问题但我从来没有得到任何答复。我真的无法在任何地方找到任何好的文档。我需要做的就是在从表单上传文件时使用工作人员(不在乎安装了 django-celery 和 rq 的工作人员)将文件转换为 flv。我能够在本地轻松完成这项工作,但一个多星期后,无论我尝试了什么,我都无法让它发挥作用。我尝试为 celery 添加 tasks.py 文件,或为 rq 添加 worker.py 文件,但我不知道还需要做什么(如果有的话),例如在我的 settings.py 或 Procfile 中。我的 procfile 看起来像:

web: gunicorn lftv.wsgi -b 0.0.0.0:$PORT
celeryd: celery -A tasks worker --loglevel=info
worker: python worker.py

我的 requirements.txt 显示了我已安装的内容,如下所示:

Django==1.4.3
Logbook==0.4.1
amqp==1.0.6
anyjson==0.3.3
billiard==2.7.3.19
boto==2.6.0
celery==3.0.13
celery-with-redis==3.0
distribute==0.6.31
dj-database-url==0.2.1
django-celery==3.0.11
django-s3-folder-storage==0.1
django-storages==1.1.6
gunicorn==0.16.1
kombu==2.5.4
pil==1.1.7
psycopg2==2.4.5
python-dateutil==1.5
pytz==2012j
redis==2.7.2
requests==1.1.0
rq==0.3.2
six==1.2.0
times==0.6

我的 settings.py 中唯一相关的内容如下:

BROKER_BACKEND = 'django'
BROKER_URL = #For this I copy/pasted the code from my redistogo add-on from heroku. Not sure if correct
BROKER_TRANSPORT_OPTIONS = {'visibility_timeout': 1800}

在不占用太多空间的情况下,我的 tasks.py 看起来像这样:

import subprocess

@task
def ffmpeg_conversion(input_file):
    converted_file = subprocess.call(input_file)
    return converted_file

我使用 S3 存储我的静态和媒体文件,并且上传工作(将上传添加到我的存储桶),但是无论我尝试什么转换都不会。有没有适合初学者的好教程?我遵循了 heroku redis 教程、celery 文档、rq 文档以及我能找到的任何其他内容,并让示例正常工作,但工作人员不会从我的角度执行命令。例如,我尝试过的许多事情之一:

...
ffmpeg = "ffmpeg -i %s -acodec mp3 -ar 22050 -f flv -s 320x240 %s" % (sourcefile, targetfile)
ffmpegresult = ffmpeg_conversion.delay(ffmpeg)
...

或使用 rq

...
q = Queue(connection=conn)
result = q.enqueue(ffmpeg_conversion, ffmpeg)
...

我似乎应该很简单,但是我完全是自学成才,从未部署过任何项目,而且似乎没有任何好的文档或教程可用于我正在尝试做的事情。我无法判断我是否完全脱离并完全错过了一些重要的东西或相对接近于让它发挥作用。我真的很感激任何输入,这让我发疯。提前致谢。

4

1 回答 1

0

I'm trying to do something similar and I don't think you need to create a worker. Why not use a custom build pack, such as https://github.com/integricho/heroku-buildpack-python-ffmpeg. If you had ffpmeg installed at the OS level, you could then issue video transformation commands from python itself, without the need for a separate worker.

Hope that helps ?

于 2013-03-09T23:58:59.947 回答