Commit a28213c8 authored by Ilya Simonov's avatar Ilya Simonov

fix generate_thumbnail

parent e8f7cc25
...@@ -32,7 +32,9 @@ def send_video_to_s3(video_id=None): ...@@ -32,7 +32,9 @@ def send_video_to_s3(video_id=None):
try: try:
log.info('Generating thumbnail...') log.info('Generating thumbnail...')
local_video.thumbnail = generate_thumbnail(file_path, video_name) thumbnail, thumbnail_name = generate_thumbnail(file_path, video_name)
key_thumbnail = f'videos/thumbnail/{thumbnail_name}'
local_video.thumbnail = upload_file(thumbnail, key_thumbnail, 'image/jpeg')
log.info('Thumbnail generated successfully!') log.info('Thumbnail generated successfully!')
except Exception as e: except Exception as e:
log.error(e) log.error(e)
......
...@@ -8,8 +8,6 @@ from moviepy.editor import VideoFileClip ...@@ -8,8 +8,6 @@ from moviepy.editor import VideoFileClip
from .models import Video, Playlist, TagToObject, DYNAMIC, PlaylistVideo from .models import Video, Playlist, TagToObject, DYNAMIC, PlaylistVideo
from cp_video.utils import asset_upload
log = logging.getLogger('send_video_to_s3') log = logging.getLogger('send_video_to_s3')
...@@ -35,16 +33,16 @@ def handle_uploaded_file(f, file_name): ...@@ -35,16 +33,16 @@ def handle_uploaded_file(f, file_name):
def generate_thumbnail(video_path, video_name): def generate_thumbnail(video_path, video_name):
clip = VideoFileClip(video_path) clip = VideoFileClip(video_path)
print('get clip successfully!') log.info('get clip successfully!')
thumbnail_name = video_name.split('.')[0] thumbnail_name = video_name.split('.')[0]
thumbnail_name = f'{settings.DOMAIN_NAME}{settings.MEDIA_ROOT}{thumbnail_name}.jpg' thumbnail_name = f'{settings.MEDIA_ROOT}{thumbnail_name}.jpg'
print('thumbnail big name', thumbnail_name)
clip.save_frame(thumbnail_name, t=1.00) clip.save_frame(thumbnail_name, t=1.00)
thumbnail = open(thumbnail_name, 'rb')
thumbnail_name = thumbnail_name.split('/')[-1] thumbnail_name = thumbnail_name.split('/')[-1]
print('thumbnail_name', thumbnail_name)
return thumbnail_name return thumbnail, thumbnail_name
def add_video_to_playlist(video): def add_video_to_playlist(video):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment