django-hls is a reusable Django application for streaming video and audio using the HLS
Project description
Django HLS
django-hls is a reusable Django application for streaming video and audio using the HLS
Requirements
- Django>=5.2.2,<6.0
- celery>=5.5.3,<6.0
- ffmpeg-progress-yield>=0.12.0,<1.0
- ffmpeg-python>=0.2.0,<0.3
You must have ffmpeg installed on your machine or container.
Installation
Install using pip:
$ pip install django-hls
Then add 'django_hls' to your INSTALLED_APPS.
INSTALLED_APPS = [
...
'django_hls',
]
Run migrations:
$ python manage.py migrate
Special configurations
If you are using Celery, you can set USE_CELERY to true.
this allows you to generate HLS format with celery
HLS_USE_CELERY = True
- If django-hls cannot connect to celery, the application will stop.
- Not using celery is not suitable for a production environment.
You can specify a specific queue that you want to use for django hls.
HLS_CELERY_QUEUE = 'celery' # default queue
- by default django-hls looking for celery queue
You can specify different production qualities.
HLS_QUALITIES = ["360", "480", "720"] # default qualities
To set the media segment duration:
HLS_SEGMENT_DURATION = 10 # default duration
Usage
django-hls uses ffmpeg to generate the HLS format, so as mentioned above, you need to install ffmpeg.
To add upload fields, inherit from the DjangoHLSMedia model.
from django.db import models
from django.core.validators import MaxValueValidator, MinValueValidator
from django_hls.models import DjangoHLSMedia
class Course(models.Model):
title = models.CharField(max_length=250)
rate = models.IntegerField(
default=1,
verbose_name='Stars',
validators=[
MaxValueValidator(5),
MinValueValidator(1)
]
)
created_date = models.DateField(auto_now_add=True)
def __str__(self):
return self.title
# this will add media, hls_file, key_file fields to model
class CourseSession(DjangoHLSMedia):
course = models.ForeignKey(Course, on_delete=models.CASCADE, related_name='course_sessions')
title = models.CharField(max_length=250)
created_date = models.DateField(auto_now_add=True)
def __str__(self):
return f'{self.course.title} - {self.title}'
Leave the hls_file and key_file fields blank and just upload the media. django-hls will fill these fields during generation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_hls-1.6.0.tar.gz.
File metadata
- Download URL: django_hls-1.6.0.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c20a04f9d4541abc73f70e842bef74142ec8cc05d70305dfdd35418331daa298
|
|
| MD5 |
2bfca3b4cb818cb1cf5c38652f559ec6
|
|
| BLAKE2b-256 |
d5bd17233364ad91d4ef3b3ac713aba5a9f07d1ddc2fe79aad1beb43fca1423d
|
File details
Details for the file django_hls-1.6.0-py3-none-any.whl.
File metadata
- Download URL: django_hls-1.6.0-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45a3fd97be88f2b8350f1c9d6e9347210ca8a66f762969fb6608080df94a6f44
|
|
| MD5 |
10d0a139765e5c18d5af90317ce0f364
|
|
| BLAKE2b-256 |
5410d0503494ef230fe8b4e2067adc3ea9805169119ef683b140b0aaa3e4e24f
|