Skip to content

RenderKit

renderkit.api.processor.RenderKit

Main public API for image and video processing.

Source code in src/renderkit/api/processor.py
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
class RenderKit:
    """Main public API for image and video processing."""

    def __init__(self) -> None:
        """Initialize RenderKit."""
        ensure_ffmpeg_env()
        setup_logging()

    def convert_exr_sequence_to_mp4(
        self,
        input_pattern: str,
        output_path: str,
        prefetch_workers: int = 1,
        fps: Optional[float] = None,
        color_space_preset: ColorSpacePreset = ColorSpacePreset.LINEAR_TO_SRGB,
        width: Optional[int] = None,
        height: Optional[int] = None,
        codec: str = "libx264",
        quality: int = 10,
        layer: Optional[str] = None,
        start_frame: Optional[int] = None,
        end_frame: Optional[int] = None,
        contact_sheet: bool = False,
        contact_sheet_config: Optional[ContactSheetConfig] = None,
    ) -> None:
        """Convert an EXR sequence to MP4 video.

        Args:
            input_pattern: Input file pattern (e.g., "render.%04d.exr")
            output_path: Output video file path
            prefetch_workers: Number of concurrent frame reads (1 disables prefetch)
            fps: Frame rate (optional, will try to auto-detect if not provided)
            color_space_preset: Color space conversion preset
            width: Output width (optional, uses source width if not provided)
            height: Output height (optional, uses source height if not provided)
            codec: Video codec (default: "libx264")
            quality: Video quality (0-10), 10 is best (default: 10)
            layer: Optional EXR layer to extract (default: None)
            start_frame: Start frame number (optional)
            end_frame: End frame number (optional)

        Example:
            >>> processor = RenderKit()
            >>> processor.convert_exr_sequence_to_mp4(
            ...     "render.%04d.exr",
            ...     "output.mp4",
            ...     fps=24.0,
            ...     quality=10,
            ...     layer="diffuse"
            ... )
        """
        config = (
            ConversionConfigBuilder()
            .with_input_pattern(input_pattern)
            .with_output_path(output_path)
            .with_prefetch_workers(prefetch_workers)
            .with_fps(fps)
            .with_color_space_preset(color_space_preset)
            .with_codec(codec)
            .with_quality(quality)
            .with_layer(layer)
        )

        if width is not None and height is not None:
            config.with_resolution(width, height)

        if start_frame is not None and end_frame is not None:
            config.with_frame_range(start_frame, end_frame)
        elif start_frame is not None:
            config.with_frame_range(start_frame, start_frame)
        elif end_frame is not None:
            config.with_frame_range(0, end_frame)

        if contact_sheet:
            config.with_contact_sheet(True, contact_sheet_config)

        conversion_config = config.build()
        converter = SequenceConverter(conversion_config)
        converter.convert()

    def convert_with_config(self, config: ConversionConfig) -> None:
        """Convert using a ConversionConfig object.

        Args:
            config: Conversion configuration object

        Example:
            >>> from renderkit.core.config import ConversionConfigBuilder
            >>> config = ConversionConfigBuilder()\\
            ...     .with_input_pattern("render.%04d.exr")\\
            ...     .with_output_path("output.mp4")\\
            ...     .with_fps(24.0)\\
            ...     .build()
            >>> processor = RenderKit()
            >>> processor.convert_with_config(config)
        """
        converter = SequenceConverter(config)
        converter.convert()

__init__()

Initialize RenderKit.

Source code in src/renderkit/api/processor.py
18
19
20
21
def __init__(self) -> None:
    """Initialize RenderKit."""
    ensure_ffmpeg_env()
    setup_logging()

convert_exr_sequence_to_mp4(input_pattern, output_path, prefetch_workers=1, fps=None, color_space_preset=ColorSpacePreset.LINEAR_TO_SRGB, width=None, height=None, codec='libx264', quality=10, layer=None, start_frame=None, end_frame=None, contact_sheet=False, contact_sheet_config=None)

Convert an EXR sequence to MP4 video.

Parameters:

Name Type Description Default
input_pattern str

Input file pattern (e.g., "render.%04d.exr")

required
output_path str

Output video file path

required
prefetch_workers int

Number of concurrent frame reads (1 disables prefetch)

1
fps Optional[float]

Frame rate (optional, will try to auto-detect if not provided)

None
color_space_preset ColorSpacePreset

Color space conversion preset

LINEAR_TO_SRGB
width Optional[int]

Output width (optional, uses source width if not provided)

None
height Optional[int]

Output height (optional, uses source height if not provided)

None
codec str

Video codec (default: "libx264")

'libx264'
quality int

Video quality (0-10), 10 is best (default: 10)

10
layer Optional[str]

Optional EXR layer to extract (default: None)

None
start_frame Optional[int]

Start frame number (optional)

None
end_frame Optional[int]

End frame number (optional)

None
Example

processor = RenderKit() processor.convert_exr_sequence_to_mp4( ... "render.%04d.exr", ... "output.mp4", ... fps=24.0, ... quality=10, ... layer="diffuse" ... )

Source code in src/renderkit/api/processor.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
def convert_exr_sequence_to_mp4(
    self,
    input_pattern: str,
    output_path: str,
    prefetch_workers: int = 1,
    fps: Optional[float] = None,
    color_space_preset: ColorSpacePreset = ColorSpacePreset.LINEAR_TO_SRGB,
    width: Optional[int] = None,
    height: Optional[int] = None,
    codec: str = "libx264",
    quality: int = 10,
    layer: Optional[str] = None,
    start_frame: Optional[int] = None,
    end_frame: Optional[int] = None,
    contact_sheet: bool = False,
    contact_sheet_config: Optional[ContactSheetConfig] = None,
) -> None:
    """Convert an EXR sequence to MP4 video.

    Args:
        input_pattern: Input file pattern (e.g., "render.%04d.exr")
        output_path: Output video file path
        prefetch_workers: Number of concurrent frame reads (1 disables prefetch)
        fps: Frame rate (optional, will try to auto-detect if not provided)
        color_space_preset: Color space conversion preset
        width: Output width (optional, uses source width if not provided)
        height: Output height (optional, uses source height if not provided)
        codec: Video codec (default: "libx264")
        quality: Video quality (0-10), 10 is best (default: 10)
        layer: Optional EXR layer to extract (default: None)
        start_frame: Start frame number (optional)
        end_frame: End frame number (optional)

    Example:
        >>> processor = RenderKit()
        >>> processor.convert_exr_sequence_to_mp4(
        ...     "render.%04d.exr",
        ...     "output.mp4",
        ...     fps=24.0,
        ...     quality=10,
        ...     layer="diffuse"
        ... )
    """
    config = (
        ConversionConfigBuilder()
        .with_input_pattern(input_pattern)
        .with_output_path(output_path)
        .with_prefetch_workers(prefetch_workers)
        .with_fps(fps)
        .with_color_space_preset(color_space_preset)
        .with_codec(codec)
        .with_quality(quality)
        .with_layer(layer)
    )

    if width is not None and height is not None:
        config.with_resolution(width, height)

    if start_frame is not None and end_frame is not None:
        config.with_frame_range(start_frame, end_frame)
    elif start_frame is not None:
        config.with_frame_range(start_frame, start_frame)
    elif end_frame is not None:
        config.with_frame_range(0, end_frame)

    if contact_sheet:
        config.with_contact_sheet(True, contact_sheet_config)

    conversion_config = config.build()
    converter = SequenceConverter(conversion_config)
    converter.convert()

convert_with_config(config)

Convert using a ConversionConfig object.

Parameters:

Name Type Description Default
config ConversionConfig

Conversion configuration object

required
Example

from renderkit.core.config import ConversionConfigBuilder config = ConversionConfigBuilder()\ ... .with_input_pattern("render.%04d.exr")\ ... .with_output_path("output.mp4")\ ... .with_fps(24.0)\ ... .build() processor = RenderKit() processor.convert_with_config(config)

Source code in src/renderkit/api/processor.py
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
def convert_with_config(self, config: ConversionConfig) -> None:
    """Convert using a ConversionConfig object.

    Args:
        config: Conversion configuration object

    Example:
        >>> from renderkit.core.config import ConversionConfigBuilder
        >>> config = ConversionConfigBuilder()\\
        ...     .with_input_pattern("render.%04d.exr")\\
        ...     .with_output_path("output.mp4")\\
        ...     .with_fps(24.0)\\
        ...     .build()
        >>> processor = RenderKit()
        >>> processor.convert_with_config(config)
    """
    converter = SequenceConverter(config)
    converter.convert()