Bases: FFMpegEncoder
Uses ffmpeg's prores-ks encoder to encode a clip to a ProRes stream.
Documentation for params and additional options can be viewed at: https://ffmpeg.org/ffmpeg-codecs.html#Private-Options-for-prores_002dks
Parameters:
Name |
Type |
Description |
Default |
profile |
|
The encoder profile. Basically Quality settings. Chooses the Standard/Default profile for 422 and the '4444' profile for 444 clips if None.
|
required
|
Source code in vsmuxtools/video/encoders/ffmpeg.py
| @dataclass(config=allow_extra)
class ProRes(FFMpegEncoder):
"""
Uses ffmpeg's prores-ks encoder to encode a clip to a ProRes stream.\n
Documentation for params and additional options can be viewed at: https://ffmpeg.org/ffmpeg-codecs.html#Private-Options-for-prores_002dks
:param profile: The encoder profile. Basically Quality settings.
Chooses the Standard/Default profile for 422 and the '4444' profile for 444 clips if None.
"""
profile: ProResProfile | int | None = None
def __post_init__(self):
if isinstance(self.profile, int) and self.profile not in ProResProfile.__members__.values():
raise error(f"{self.profile} is not a valid ProRes profile!", self)
super().__post_init__()
def encode(self, clip: vs.VideoNode, outfile: PathLike | None = None) -> VideoFile:
clipf = get_video_format(clip)
if clipf.subsampling_h != 0:
raise error("ProRes only supports 422 and 444 subsampling clips.", self)
if clipf.bits_per_sample > 12:
raise error("ProRes only supports bitdepths at or below 12.", self)
profile = self.profile
if profile is None:
profile = ProResProfile.DEFAULT if clipf.subsampling_w == 1 else ProResProfile.P4444
if profile in range(0, 4) and clipf.subsampling_w != 1:
raise error(f"Profile '{ProResProfile(profile).name}' only supports 422.", self)
if profile in range(4, 5) and clipf.subsampling_w != 0:
raise error(f"Profile '{ProResProfile(profile).name}' only supports 444.", self)
out = make_output("prores", "mkv", user_passed=outfile)
input_args, prop_args = self.input_args(clip)
args = self._default_args() + input_args + ["-c:v", "prores_ks"] + prop_args + self.get_custom_args() + ["-profile", str(profile)]
args.append(str(out))
process = subprocess.Popen(args, stdin=subprocess.PIPE)
self.update_process_affinity(process.pid)
clip.output(process.stdin, y4m=True)
process.communicate()
return VideoFile(out)
|