Thumbnails for images and videos #87
@ -39,12 +39,14 @@ def make_thumbnails(file_id: int) -> None:
|
||||
return
|
||||
|
||||
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)
|
||||
|
||||
if file.is_video:
|
||||
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)
|
||||
source_path = f_path
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user