mirror of
https://github.com/master-of-zen/Av1an.git
synced 2024-11-25 02:29:40 +00:00
54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
|
from pathlib import Path
|
||
|
|
||
|
from .arg_parse import Args
|
||
|
import Av1an
|
||
|
|
||
|
|
||
|
class Chunk:
|
||
|
"""
|
||
|
Chunk class. Stores information relating to a chunk. The command that gets the chunk and the encoding commands
|
||
|
to be run on this chunk.
|
||
|
"""
|
||
|
|
||
|
def __init__(self, index: int, ffmpeg_gen_cmd: str, size: int, temp: Path, frames: int, output_ext: str):
|
||
|
self.index = index
|
||
|
self.ffmpeg_gen_cmd = ffmpeg_gen_cmd
|
||
|
self.size = size
|
||
|
self.temp = temp
|
||
|
self.pass_cmds = []
|
||
|
self.frames = frames
|
||
|
self.output_ext = output_ext
|
||
|
|
||
|
def generate_pass_cmds(self, args: Args):
|
||
|
self.pass_cmds = Av1an.gen_pass_commands(args, self)
|
||
|
|
||
|
def remove_first_pass_from_commands(self):
|
||
|
"""
|
||
|
Removes the first pass command from the list of commands since we generated the first pass file ourselves.
|
||
|
|
||
|
:return: None
|
||
|
"""
|
||
|
# just one pass to begin with, do nothing
|
||
|
if len(self.pass_cmds) == 1:
|
||
|
return
|
||
|
|
||
|
# passes >= 2, remove the command for first pass (pass_cmds[0])
|
||
|
self.pass_cmds = self.pass_cmds[1:]
|
||
|
|
||
|
@property
|
||
|
def output_path(self) -> Path:
|
||
|
return (self.temp / 'encode') / f'{self.name}.{self.output_ext}'
|
||
|
|
||
|
@property
|
||
|
def output(self) -> str:
|
||
|
return self.output_path.as_posix()
|
||
|
|
||
|
@property
|
||
|
def fpf(self) -> str:
|
||
|
fpf_file = (self.temp / 'split') / f'{self.name}_fpf'
|
||
|
return fpf_file.as_posix()
|
||
|
|
||
|
@property
|
||
|
def name(self):
|
||
|
return str(self.index).zfill(5)
|