update documentation

This commit is contained in:
Chneemann 2024-08-19 22:09:05 +02:00
parent f3a0582428
commit 6ba9a41404
2 changed files with 7 additions and 2 deletions

View file

@ -9,9 +9,8 @@ import shutil
@receiver(post_save, sender=Video)
def video_post_save(sender, instance, created, **kwargs):
"""
Generates a thumbnail for a newly created `Video` instance.
Generates a thumbnail, enqueues tasks to convert the video to different resolutions, and schedules the deletion of the original video file.
"""
# With Django RQ Worker (My server is too slow for it)
if created:
queue = django_rq.get_queue("default", autocommit=True)

View file

@ -5,6 +5,9 @@ import os
from django.conf import settings
def convert_video_to_hls(source, resolution, model_id):
"""
Converts a video to the HLS format
"""
target_dir = os.path.join(os.path.dirname(source), str(model_id))
os.makedirs(target_dir, exist_ok=True)
@ -38,6 +41,9 @@ def delete_original_video(source):
print(f"Error deleting original file: {e}")
def create_thumbnails(instance, model_id):
"""
Creates high-resolution and low-resolution thumbnails from a video file
"""
video_file_path = instance.video_file.path
thumbnail_dir = os.path.join(settings.THUMBNAIL_DIR, str(model_id))