diff --git a/zou/app/services/preview_files_service.py b/zou/app/services/preview_files_service.py index 0b37c00517..bf61c6072c 100644 --- a/zou/app/services/preview_files_service.py +++ b/zou/app/services/preview_files_service.py @@ -649,6 +649,7 @@ def generate_tiles_for_movie_previews(): try: path = extract_tile_from_preview_file(preview_file.serialize()) file_store.add_picture("tiles", str(preview_file.id), path) + os.remove(path) print( f"Tile generated for preview file {preview_file.id}", ) @@ -793,6 +794,7 @@ def generate_tiles_and_reset_preview_files_metadata(): file_store.add_picture( "tiles", preview_file_id, extracted_tile_path ) + os.remove(extracted_tile_path) print( f"Tile generated for preview file {preview_file_id}", ) diff --git a/zou/utils/movie.py b/zou/utils/movie.py index 39b0ba8e7a..7ad433d1d0 100644 --- a/zou/utils/movie.py +++ b/zou/utils/movie.py @@ -10,6 +10,8 @@ import ffmpeg import opentimelineio as otio +from zou.app import config + logger = logging.getLogger(__name__) loghandler = logging.StreamHandler() loghandler.setLevel(logging.INFO) @@ -54,10 +56,9 @@ def generate_thumbnail(movie_path): Generate a thumbnail to represent the movie given at movie path. It takes a picture at the first frame of the movie. """ - folder_path = os.path.dirname(movie_path) file_source_name = os.path.basename(movie_path) file_target_name = "%s.png" % file_source_name[:-4] - file_target_path = os.path.join(folder_path, file_target_name) + file_target_path = os.path.join(config.TMP_DIR, file_target_name) try: ffmpeg.input(movie_path, ss="00:00:00").output( @@ -74,10 +75,9 @@ def extract_frame_from_movie(movie_path, frame_number, movie_fps): Extract a frame from the movie given at movie path. It takes a picture at the specified time of the movie. """ - folder_path = os.path.dirname(movie_path) file_source_name = os.path.basename(movie_path) file_target_name = f"{file_source_name[:-4]}_{frame_number}.png" - file_target_path = os.path.join(folder_path, file_target_name) + file_target_path = os.path.join(config.TMP_DIR, file_target_name) frame_time = otio.opentime.RationalTime( frame_number - 1, float(movie_fps) @@ -98,10 +98,9 @@ def generate_tile(movie_path, movie_fps): """ Generates a tile from a movie. """ - folder_path = os.path.dirname(movie_path) file_source_name = os.path.basename(movie_path) file_target_name = f"{file_source_name[:-4]}_tile.png" - file_target_path = os.path.join(folder_path, file_target_name) + file_target_path = os.path.join(config.TMP_DIR, file_target_name) probe = ffmpeg.probe(movie_path) duration_in_seconds = float(probe["streams"][0]["duration"]) float_movie_fps = float(movie_fps) @@ -190,12 +189,11 @@ def normalize_movie(movie_path, fps, width, height): Normalize movie using resolution, width and height given in parameter. Generates a high def movie and a low def movie. """ - folder_path = os.path.dirname(movie_path) file_source_name = os.path.basename(movie_path) file_target_name = "%s.mp4" % file_source_name[:-8] - file_target_path = os.path.join(folder_path, file_target_name) + file_target_path = os.path.join(config.TMP_DIR, file_target_name) low_file_target_name = "%s_low.mp4" % file_source_name[:-8] - low_file_target_path = os.path.join(folder_path, low_file_target_name) + low_file_target_path = os.path.join(config.TMP_DIR, low_file_target_name) (w, h) = get_movie_size(movie_path) resize_factor = w / h