init commit
This commit is contained in:
17
video/tasks.py
Normal file
17
video/tasks.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from celery import shared_task
|
||||
import os
|
||||
from django.conf import settings
|
||||
import ffmpeg_streaming
|
||||
from ffmpeg_streaming import Formats, Bitrate, Representation, Size
|
||||
from django.core.files.storage import default_storage
|
||||
|
||||
@shared_task()
|
||||
def create_hls_tasks(filename):
|
||||
end_location = str(settings.MEDIA_ROOT) + "/" + str(filename) +'.m3u8'
|
||||
if not default_storage.exists(end_location):
|
||||
media_location = str(settings.MEDIA_ROOT) + "/" + str(filename)
|
||||
video = ffmpeg_streaming.input(media_location)
|
||||
hls = video.hls(Formats.h264())
|
||||
_720p = Representation(Size(1280, 720), Bitrate(2048 * 1024, 320 * 1024))
|
||||
hls.representations(_720p)
|
||||
hls.output(end_location)
|
||||
Reference in New Issue
Block a user