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.
Metadata
Release files for django-hls 1.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_hls-1.6.0.tar.gz | 8.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_hls-1.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.9 kB
Release files / django_hls-1.6.0.tar.gz
| Download URL | django_hls-1.6.0.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c20a04f9d4541abc73f70e842bef74142ec8cc05d70305dfdd35418331daa298
|
|
BLAKE2b-256 checksum How to use checksums |
d5bd17233364ad91d4ef3b3ac713aba5a9f07d1ddc2fe79aad1beb43fca1423d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Release files / django_hls-1.6.0-py3-none-any.whl
| Download URL | django_hls-1.6.0-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
45a3fd97be88f2b8350f1c9d6e9347210ca8a66f762969fb6608080df94a6f44
|
|
BLAKE2b-256 checksum How to use checksums |
5410d0503494ef230fe8b4e2067adc3ea9805169119ef683b140b0aaa3e4e24f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|