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

发布于 2022-09-12 22:39:51 字数 4423 浏览 18 评论 0

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录制直播视频~~~~

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文