Пример #1
0
def build_playlist_movie_file(playlist, app=None):
    """
    Build a movie for all files for a given playlist into the temporary folder.
    """
    job = start_build_job(playlist)
    project = projects_service.get_project(playlist["project_id"])
    tmp_file_paths = retrieve_playlist_tmp_files(playlist, only_movies=True)
    movie_file_path = get_playlist_movie_file_path(playlist, job)
    (width, height) = shots_service.get_preview_dimensions(project)
    fps = shots_service.get_preview_fps(project)

    result = movie_utils.build_playlist_movie(tmp_file_paths, movie_file_path,
                                              width, height, fps)
    if result["success"] == True:
        if os.path.exists(movie_file_path):
            file_store.add_movie("playlists", job["id"], movie_file_path)
        else:
            if app is not None:
                current_app.logger.error("No playlist was created")
            result["success"] = False
            result["message"] = "No playlist was created"

    elif app is not None:
        current_app.logger.error(result["message"])
    end_build_job(playlist, job, result)
    return job
Пример #2
0
    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)
Пример #3
0
def build_playlist_movie_file(playlist):
    """
    Build a movie for all files for a given playlist into the temporary folder.
    """
    job = start_build_job(playlist)
    project = projects_service.get_project(playlist["project_id"])
    tmp_file_paths = retrieve_playlist_tmp_files(playlist)
    movie_file_path = get_playlist_movie_file_path(playlist, job)
    (width, height) = shots_service.get_preview_dimensions(project)
    fps = shots_service.get_preview_fps(project)

    movie_utils.build_playlist_movie(
        tmp_file_paths,
        movie_file_path,
        width,
        height,
        fps
    )
    file_store.add_movie("playlists", job["id"], movie_file_path)
    end_build_job(playlist, job)
    return job