Thumbnails for images and videos #87

Merged
Anna Sirota merged 28 commits from thumbnails into main 2024-04-25 17:50:58 +02:00
Showing only changes of commit 8d156244c5 - Show all commits

View File

@ -39,12 +39,14 @@ def make_thumbnails(file_id: int) -> None:
return return
assert file.validation.is_ok, f'File pk={file_id} is flagged' assert file.validation.is_ok, f'File pk={file_id} is flagged'
assert file.is_image or file.is_video, f'File pk={file_id} is neither image nor video'
# For an image, source of the thumbnails is the original image
source_path = os.path.join(settings.MEDIA_ROOT, file.source.path) source_path = os.path.join(settings.MEDIA_ROOT, file.source.path)
if file.is_video: if file.is_video:
f_path = os.path.join(settings.MEDIA_ROOT, files.utils.get_thumbnail_upload_to(file.hash)) f_path = os.path.join(settings.MEDIA_ROOT, files.utils.get_thumbnail_upload_to(file.hash))
# For a video, source of the thumbnail is some frame fetched with ffpeg # For a video, source of the thumbnails is a frame extracted with ffpeg
files.utils.extract_frame(source_path, f_path) files.utils.extract_frame(source_path, f_path)
source_path = f_path source_path = f_path