diff --git a/web_server/celery_tasks/streaming.py b/web_server/celery_tasks/streaming.py index 9808973..daa6f84 100644 --- a/web_server/celery_tasks/streaming.py +++ b/web_server/celery_tasks/streaming.py @@ -4,8 +4,11 @@ from celery_tasks.preferences import user_preferences from utils.stream_utils import generate_thumbnail, get_streamer_live_status, get_custom_thumbnail_status, remove_hls_files from time import sleep from os import listdir, remove +from utils.path_manager import PathManager import subprocess +path_manager = PathManager() + @shared_task def update_thumbnail(user_id, stream_file, thumbnail_file, sleep_time) -> None: """ @@ -21,7 +24,7 @@ def update_thumbnail(user_id, stream_file, thumbnail_file, sleep_time) -> None: print(f"Stopping thumbnail updates for stream of {user_id}") @shared_task -def combine_ts_stream(stream_path, vods_path, vod_file_name): +def combine_ts_stream(stream_path, vods_path, vod_file_name, thumbnail_file) -> None: """ Combines all ts files into a single vod, and removes the ts files """ @@ -53,6 +56,9 @@ def combine_ts_stream(stream_path, vods_path, vod_file_name): # Remove HLS files, even if user is not streaming remove_hls_files(stream_path) + # Generate thumbnail for vod + generate_thumbnail(f"{vods_path}/{vod_file_name}.mp4", thumbnail_file) + @shared_task def convert_image_to_png(image_path, png_path): """ diff --git a/web_server/utils/stream_utils.py b/web_server/utils/stream_utils.py index e71b5e6..ec0fb30 100644 --- a/web_server/utils/stream_utils.py +++ b/web_server/utils/stream_utils.py @@ -113,7 +113,8 @@ def end_user_stream(stream_key, user_id, username): combine_ts_stream.delay( path_manager.get_stream_path(username), path_manager.get_vods_path(username), - vod_id + vod_id, + path_manager.get_vod_thumbnail_file_path(username, vod_id) ) print(f"Stream ended for user {username} (ID: {user_id})", flush=True)