Ambitiont109 / django_celery_hls_ffmpeg_nginx

Implemented HLS server with Django and Nignx RTMP and FFMpeg. Also used the celery to stream in the background

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Basic Django Celery Example for HLS (Http Live Streaming) with ffmpeg

You could git clone this repository to get it working but I recommend following these manual steps so you understand what's required to get a basic Celery example up and running.

  • Before you start, you'll need a Redis server. If you don't have one the easiest way is through Docker with the following command:
docker run --name my-redis-server -d -p 127.0.0.1:6379:6379 redis
  • Also you have to install ffmpeg for streaming
sudo apt update
sudo apt install ffmpeg
  • Create a virtual environment using the method of your choice, I like to use the following command:
python3.8 -m venv .venv && source .venv/bin/activate && pip install --upgrade pip wheel setuptools > /dev/null
  • Create the requirements.txt file to install the packages required:
django
redis
celery
  • Activate your virtual environment and install the requirements in the requirements.txt file:
pip install -r requirements.txt
  • Now you need to launch the Django test server:
python manage.py runserver
  • Then in a second terminal window, navigate to your project directory, activate the virtual environment again, and then launch the Celery process - it should print out some debug information and then a ready message to indicate it has connected to Redis successfully and is waiting for tasks:
python -m celery -A celery_project worker -l info -P solo
  • Browse to http://127.0.0.1 and you should see a form. Try inputing a url of the video , it can be local file url or stream link
  • After start streaming, you should see the streamed url.

Hopefully that worked for you and gives you something to build upon.

About

Implemented HLS server with Django and Nignx RTMP and FFMpeg. Also used the celery to stream in the background


Languages

Language:Python 84.1%Language:HTML 15.9%