Skip to content

Settings

FPS dataclass

Set the frame rate (Hz value, fraction or abbreviation).

Usage:

# frame per seconds
fps = FPS(fs=60)
Source code in nucleus/sdk/processing/video/settings.py
61
62
63
64
65
66
67
68
69
70
71
72
73
74
@dataclass(slots=True)
class FPS:
    """Set the frame rate (Hz value, fraction or abbreviation).

    Usage:

        # frame per seconds
        fps = FPS(fs=60)
    """

    fps: float

    def __iter__(self):
        yield 'r', self.fps

BR dataclass

Set the Video/Audio bitrate.

Usage:

# set bitrate for both streams or independent
br = BR(100) # audio/video
br = BR(150, 94) # video b:v 150, audio b:a 94
Source code in nucleus/sdk/processing/video/settings.py
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
@dataclass(slots=True)
class BR:
    """Set the Video/Audio bitrate.

    Usage:

        # set bitrate for both streams or independent
        br = BR(100) # audio/video
        br = BR(150, 94) # video b:v 150, audio b:a 94

    """

    video: int
    audio: int = 0

    def __iter__(self):
        # if we only receive video bitrate, we consider it as overall bitrate
        if self.video and not self.audio:
            yield 'b', f'{self.video}k'
            return

        yield 'b:v', f'{self.video}k'
        yield 'b:a', f'{self.audio}k'

Custom dataclass

Special class for directly specifying custom settings to the ffmpeg command.

Usage:

# create a custom command based on ffmpeg option -fs
# No further chunk of bytes is written after the limit is exceeded.
custom = Custom(fs=100)
Source code in nucleus/sdk/processing/video/settings.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
@dataclass(slots=True)
class Custom:
    """Special class for directly specifying custom settings to the ffmpeg command.

    Usage:

        # create a custom command based on ffmpeg option -fs
        # No further chunk of bytes is written after the limit is exceeded.
        custom = Custom(fs=100)
    """

    _custom: Mapping[str, Any]

    def __init__(self, **kwargs: Any):
        self._custom = kwargs

    def __iter__(self):
        yield from self._custom.items()

FrameSize dataclass

Set the frame size.

Usage:

# the output screen size
size = FrameSize(200, 200)
Source code in nucleus/sdk/processing/video/settings.py
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
@dataclass(slots=True)
class FrameSize:
    """Set the frame size.

    Usage:

        # the output screen size
        size = FrameSize(200, 200)
    """

    width: int
    height: int

    def __str__(self) -> str:
        return f'{self.width}x{self.height}'

    def __iter__(self):
        yield 's', str(self)

Defaults

Screen dataclass

Default standard screen size settings.

Usage:

# using default screen sizes
br = Screen.Q720 # appropriate size 720p
Source code in nucleus/sdk/processing/video/settings.py
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
@dataclass(frozen=True)
class Screen:
    """Default standard screen size settings.

    Usage:

        # using default screen sizes
        br = Screen.Q720 # appropriate size 720p

    """

    Q240 = FrameSize(416, 234)
    Q360 = FrameSize(640, 360)
    Q480 = FrameSize(854, 480)
    Q720 = FrameSize(1280, 720)
    Q1080 = FrameSize(1920, 1080)
    Q2k = FrameSize(2560, 1440)
    Q4k = FrameSize(3840, 2160)

Bitrate dataclass

Default standard bitrate settings.

Usage:

# using default standard bitrate
br = Bitrate.B720 # appropriate bitrate for 720p
Source code in nucleus/sdk/processing/video/settings.py
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
@dataclass(frozen=True)
class Bitrate:
    """Default standard bitrate settings.

    Usage:

        # using default standard bitrate
        br = Bitrate.B720 # appropriate bitrate for 720p
    """

    B240 = BR(150, 94)
    B360 = BR(276, 128)
    B480 = BR(750, 192)
    B720 = BR(2048, 320)
    B1080 = BR(4096, 320)
    B2k = BR(6144, 320)
    B4k = BR(17408, 320)

Note

During processing time, the setting classes are parsed as configuration arguments for FFMPEG python library. To know more about the settings implemented in this reference please see FFMPEG main options.