def save_movie_preview(self, instance_id, uploaded_file): """ Get uploaded movie, normalize it (720p) then build thumbnails then save everything in the file storage. """ tmp_folder = current_app.config["TMP_DIR"] fps = "24.00" uploaded_movie_path = movie_utils.save_file( tmp_folder, instance_id, uploaded_file ) project = files_service.get_project_from_preview_file(instance_id) if project["fps"] is not None: fps = "%.2f" % float(project["fps"].replace(",", ".")) normalized_movie_path = movie_utils.normalize_movie( uploaded_movie_path, fps=fps ) file_store.add_movie("previews", instance_id, normalized_movie_path) original_tmp_path = movie_utils.generate_thumbnail( normalized_movie_path ) os.remove(uploaded_movie_path) os.remove(normalized_movie_path) return self.save_variants(original_tmp_path, instance_id)
def save_movie_preview(self, instance_id, uploaded_file): """ Get uploaded movie, normalize it (720p) then build thumbnails then save everything in the file storage. """ tmp_folder = current_app.config["TMP_DIR"] uploaded_movie_path = movie_utils.save_file(tmp_folder, instance_id, uploaded_file) normalized_movie_path = movie_utils.normalize_movie( uploaded_movie_path) file_store.add_movie("previews", instance_id, normalized_movie_path) original_tmp_path = movie_utils.generate_thumbnail( normalized_movie_path) os.remove(uploaded_movie_path) os.remove(normalized_movie_path) return self.save_variants(original_tmp_path, instance_id)
def prepare_and_store_movie(preview_file_id, uploaded_movie_path): """ Prepare movie preview, normalize the movie as a .mp4, build the thumbnails and store the files. """ from zou.app import app as current_app with current_app.app_context(): project = get_project_from_preview_file(preview_file_id) fps = get_preview_file_fps(project) (width, height) = get_preview_file_dimensions(project) # Build movie current_app.logger.info("start normalization") try: normalized_movie_path = movie_utils.normalize_movie( uploaded_movie_path, fps=fps, width=width, height=height) current_app.logger.info("file normalized %s" % normalized_movie_path) file_store.add_movie("previews", preview_file_id, normalized_movie_path) current_app.logger.info("file stored") except: current_app.logger.error("failed", exc_info=1) preview_file = set_preview_file_as_broken(preview_file_id) return preview_file # Build thumbnails size = movie_utils.get_movie_size(normalized_movie_path) original_picture_path = \ movie_utils.generate_thumbnail(normalized_movie_path) tile_picture_path = \ movie_utils.generate_tile(normalized_movie_path) thumbnail_utils.resize(original_picture_path, size) save_variants(preview_file_id, original_picture_path) file_size = os.path.getsize(normalized_movie_path) current_app.logger.info("thumbnail created %s" % original_picture_path) # Remove files and update status os.remove(uploaded_movie_path) os.remove(normalized_movie_path) preview_file = update_preview_file(preview_file_id, { "status": "ready", "file_size": file_size }) return preview_file
def save_movie_preview(self, instance_id, uploaded_file): """ Get uploaded movie, normalize it then build thumbnails then save everything in the file storage. """ tmp_folder = current_app.config["TMP_DIR"] uploaded_movie_path = movie_utils.save_file(tmp_folder, instance_id, uploaded_file) project = files_service.get_project_from_preview_file(instance_id) fps = shots_service.get_preview_fps(project) (width, height) = shots_service.get_preview_dimensions(project) normalized_movie_path = movie_utils.normalize_movie( uploaded_movie_path, fps=fps, width=width, height=height) file_store.add_movie("previews", instance_id, normalized_movie_path) original_tmp_path = movie_utils.generate_thumbnail( normalized_movie_path) os.remove(uploaded_movie_path) os.remove(normalized_movie_path) return self.save_variants(original_tmp_path, instance_id)