如何实现django后台录制直播?

本人...
  • -3
新手上路,请多包涵
Django + ffmpeg
Django后台录制视频
tasks任务
from celery import shared_task
import subprocess
from testCode.example_m3u8 import get_real_url
from mysite.celery import app

@app.task
def start_recording():
    url = get_real_url('11342412')
    ff = r"ffmpeg -y  -reconnect_streamed 1 -reconnect_delay_max 20 -rw_timeout 20000000 -i '{}'  -bsf:a aac_adtstoasc -fs 871440000 -c copy -f flv /home/admin/output.flv".format(url)
    subprocess.Popen(ff,shell=True)

views接受get请求开始任务
#views
@login_required
def start_recoding(request):
    if request.method == 'GET':
        from .tasks import start_recording
        start_recording.delay()
        return HttpResponse('ok')

这是debug报错内容

./testCode/views.py`, line 143, in start_recoding

136.      return render(request, 'test/management.html', {'video_list': c, 'text': t})
    

139.  @login_required
    
140.  def start_recoding(request):
    
141.      if request.method == 'GET':
    
142.          from .tasks import start_recording
    
                #这条代码执行不下去
143.         ** start_recording.delay()**
    
    …

144.          return HttpResponse('ok')

  File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.8/dist-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/home/admin/mysite/testCode/views.py", line 145, in start_recoding
    test.delay()
  File "/usr/local/lib/python3.8/dist-packages/celery/app/task.py", line 461, in delay
    return self.apply_async(args, kwargs)
  File "/usr/local/lib/python3.8/dist-packages/celery/app/task.py", line 570, in apply_async
    return app.send_task(
  File "/usr/local/lib/python3.8/dist-packages/celery/app/base.py", line 348, in send_task
    with self.producer_or_acquire(producer) as P:
  File "/usr/local/lib/python3.8/dist-packages/celery/app/base.py", line 403, in producer_or_acquire
    producer, self.amqp.producer_pool.acquire, block=True,
  File "/usr/local/lib/python3.8/dist-packages/celery/app/amqp.py", line 502, in producer_pool
    self.app.pool,
  File "/usr/local/lib/python3.8/dist-packages/celery/app/base.py", line 617, in pool
    self._pool = self.connection().Pool(limit=limit)
  File "/usr/local/lib/python3.8/dist-packages/celery/app/base.py", line 369, in connection
    return self.amqp.Connection(
  File "/usr/local/lib/python3.8/dist-packages/kombu/connection.py", line 177, in __init__
    if not get_transport_cls(transport).can_parse_url:
  File "/usr/local/lib/python3.8/dist-packages/kombu/transport/__init__.py", line 109, in get_transport_cls
    _transport_cache[transport] = resolve_transport(transport)
  File "/usr/local/lib/python3.8/dist-packages/kombu/transport/__init__.py", line 93, in resolve_transport
    return symbol_by_name(transport)
  File "/usr/local/lib/python3.8/dist-packages/kombu/utils/__init__.py", line 96, in symbol_by_name
    module = imp(module_name, package=package, **kwargs)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 779, in exec_module
  File "<frozen importlib._bootstrap_external>", line 916, in get_code
  File "<frozen importlib._bootstrap_external>", line 846, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/local/lib/python3.8/dist-packages/kombu/transport/redis.py", line 815
    def _connparams(self, async=False, _r210_options=(
                          ^
SyntaxError: invalid syntax


我想请问怎么完善我的代码 能指点下我哪里出错了,或者给我更多思路完成我要功能
我要的功能是前端get请求 views celery异步任务 ffmpeg录制直播视频~~~~
回复
阅读 384
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
你知道吗?

宣传栏