예제 #1
0
 def startup(self, project: Project, chunk_queue: List[Chunk]):
     clips = len(chunk_queue)
     project.workers = min(project.workers, clips)
     print(
         f"\rQueue: {clips} Workers: {project.workers} Passes: {project.passes}\n"
         f'Params: {" ".join(project.video_params)}')
     BaseManager.register("Counter", Counter)
     counter = Manager().Counter(project.get_frames(), self.initial_frames,
                                 not project.quiet)
     project.counter = counter
예제 #2
0
파일: Manager.py 프로젝트: natis1/Pav1n
 def create_project_list(self):
     """
     Returns list of initialized Project objects with single input
     """
     queue = []
     for file in self.file_queue:
         project = Project(vars(self.args))
         project.input = file
         project.outputs_filenames()
         queue.append(project)
     return queue
예제 #3
0
    def done_file(self, project: Project, chunk_queue: List[Chunk]):
        done_path = project.temp / "done.json"
        if project.resume and done_path.exists():
            log("Resuming...")
            with open(done_path) as done_file:
                data = json.load(done_file)

            project.set_frames(data["frames"])
            done = len(data["done"])
            self.initial_frames = sum(data["done"].values())
            log(f"Resumed with {done} encoded clips done")
        else:
            self.initial_frames = 0
            total = project.get_frames()
            d = {"frames": total, "done": {}}
            with open(done_path, "w") as done_file:
                json.dump(d, done_file)
예제 #4
0
파일: Manager.py 프로젝트: natis1/Pav1n
    def done_file(self, project: Project, chunk_queue: List[Chunk]):
        done_path = project.temp / 'done.json'
        if project.resume and done_path.exists():
            log('Resuming...\n')
            with open(done_path) as done_file:
                data = json.load(done_file)

            project.set_frames(data['frames'])
            done = len(data['done'])
            self.initial_frames = sum(data['done'].values())
            log(f'Resumed with {done} encoded clips done\n\n')
        else:
            self.initial_frames = 0
            total = project.get_frames()
            d = {'frames': total, 'done': {}}
            with open(done_path, 'w') as done_file:
                json.dump(d, done_file)
예제 #5
0
    def encode_file(self, project: Project):
        """
        Encodes a single video file on the local machine.

        :param project: The project for this encode
        :return: None
        """

        project.setup()
        set_log(project.logging, project.temp)

        # find split locations
        split_locations = split_routine(project, project.resume)

        # create a chunk queue
        chunk_queue = load_or_gen_chunk_queue(project, project.resume,
                                              split_locations)

        self.done_file(project, chunk_queue)
        if not project.resume:
            extract_audio(
                str(project.input.resolve()),
                str(project.temp.resolve()),
                project.audio_params,
            )

        # do encoding loop
        project.determine_workers()
        self.startup(project, chunk_queue)
        queue = Queue(project, chunk_queue)
        queue.encoding_loop()

        if queue.status.lower() == "fatal":
            msg = "FATAL Encoding process encountered fatal error, shutting down"
            print("\n::", msg)
            log(msg)
            sys.exit(1)

        # concat
        project.concat_routine()

        if project.vmaf or project.vmaf_plots:
            self.vmaf = VMAF(
                n_threads=project.n_threads,
                model=project.vmaf_path,
                res=project.vmaf_res,
                vmaf_filter=project.vmaf_filter,
            )
            self.vmaf.plot_vmaf(project.input, project.output_file, project)

        # Delete temp folders
        if not project.keep:
            shutil.rmtree(project.temp)