packets ¶
Classes:
-
ScenePacketStats
–A class representing the packet size statistics for a scene in a video.
-
VideoPackets
–A class representing video packet sizes for each frame in a video.
ScenePacketStats ¶
Bases: TypedDict
A class representing the packet size statistics for a scene in a video.
Attributes:
-
PktSceneAvgSize
(float
) –The average packet size for the scene.
-
PktSceneMaxSize
(float
) –The maximum packet size for the scene.
-
PktSceneMinSize
(float
) –The minimum packet size for the scene.
VideoPackets ¶
A class representing video packet sizes for each frame in a video.
Packet sizes are useful for analyzing video encoding characteristics such as bitrate, allowing you to process frames and/or scenes based on packet sizes.
Methods:
-
apply_props
–Apply packet size properties to a clip.
-
from_clip
–Obtain packet sizes from a given clip.
-
from_file
–Obtain packet sizes from a given file.
-
from_video
–Obtain packet sizes from a video file.
-
get_scenestats
–Calculate scene-based packet size statistics by referencing Keyframes.
apply_props ¶
apply_props(
clip: VideoNodeT,
keyframes: Keyframes | None = None,
*,
func: FuncExceptT | None = None
) -> VideoNodeT
Apply packet size properties to a clip.
Parameters:
-
clip
¶VideoNodeT
) –The clip to apply the packet size properties to.
-
keyframes
¶Keyframes | None
, default:None
) –The keyframe list to get scene packet statistics for. If None, the packet size properties will be applied to each frame. Default: None.
-
func
¶FuncExceptT | None
, default:None
) –An optional function to use for error handling. This should only be set by package developers.
Returns:
-
VideoNodeT
–A clip with the packet size properties applied.
Source code
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
|
from_clip classmethod
¶
from_clip(
clip: VideoNode,
out_file: SPathLike,
src_file: SPathLike | None = None,
offset: int = 0,
*,
func: FuncExceptT | None = None
) -> Self
Obtain packet sizes from a given clip.
Parameters:
-
clip
¶VideoNode
) –The clip to obtain packet sizes from. Must have the
IdxFilePath
frame property. -
out_file
¶SPathLike
) –The path to the output file where packet sizes will be saved.
-
src_file
¶SPathLike | None
, default:None
) –The path to the source video file. If None, the source file will be obtained from the clip. Default: None.
Source code
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
from_file classmethod
¶
Obtain packet sizes from a given file.
Parameters:
-
file
¶SPathLike
) –The path to the file containing the packet sizes.
-
func
¶FuncExceptT | None
, default:None
) –An optional function to use for error handling. This should only be set by package developers.
Returns:
-
Self | None
–A VideoPackets object containing the packet sizes.
Source code
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
from_video classmethod
¶
from_video(
src_file: SPathLike,
out_file: SPathLike | None = None,
offset: int = 0,
*,
func: FuncExceptT | None = None
) -> Self
Obtain packet sizes from a video file.
If the packet sizes are already calculated, they will be read from the output file. Otherwise, this method will use ffprobe
to calculate the packet sizes and save them to the output file.
offset
can be used to remove or add frames from the start of the list. This is useful for applying the packet sizes to a trimmed clip. Positive values will trim the start of the list, and negative values will duplicate packets at the start of the list.
Parameters:
-
src_file
¶SPathLike
) –The path to the source video file.
-
out_file
¶SPathLike | None
, default:None
) –The path to the output file where packet sizes will be saved. If None, output file will be placed alongside the source file. Default: None.
-
offset
¶int
, default:0
) –An optional integer offset to trim the packet sizes. This is useful for applying the packet sizes to a trimmed clip. Positive values will trim the start of the list, and negative values will duplicate packets at the start of the list. Default: 0.
-
func
¶FuncExceptT | None
, default:None
) –An optional function to use for error handling. This should only be set by package developers.
Returns:
-
Self
–A VideoPackets object containing the packet sizes.
Source code
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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
get_scenestats ¶
get_scenestats(keyframes: Keyframes) -> list[ScenePacketStats]
Calculate scene-based packet size statistics by referencing Keyframes.
Parameters:
Returns:
-
list[ScenePacketStats]
–A list of ScenePacketStats objects.
Source code
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
|