@@ -150,6 +150,15 @@ def _getitem_slice(self, key: slice) -> Tensor:
|
150 | 150 | def __getitem__(self, key: Union[numbers.Integral, slice]) -> Tensor:
|
151 | 151 | """Return frame or frames as tensors, at the given index or range.
|
152 | 152 |
|
| 153 | +.. note:: |
| 154 | +
|
| 155 | +If you need to decode multiple frames, we recommend using the batch |
| 156 | +methods instead, since they are faster: |
| 157 | +:meth:`~torchcodec.decoders.VideoDecoder.get_frames_at`, |
| 158 | +:meth:`~torchcodec.decoders.VideoDecoder.get_frames_in_range`, |
| 159 | +:meth:`~torchcodec.decoders.VideoDecoder.get_frames_played_at`, and |
| 160 | +:meth:`~torchcodec.decoders.VideoDecoder.get_frames_played_in_range`. |
| 161 | +
|
153 | 162 | Args:
|
154 | 163 | key(int or slice): The index or range of frame(s) to retrieve.
|
155 | 164 |
|
@@ -171,6 +180,15 @@ def _get_key_frame_indices(self) -> list[int]:
|
171 | 180 | def get_frame_at(self, index: int) -> Frame:
|
172 | 181 | """Return a single frame at the given index.
|
173 | 182 |
|
| 183 | +.. note:: |
| 184 | +
|
| 185 | +If you need to decode multiple frames, we recommend using the batch |
| 186 | +methods instead, since they are faster: |
| 187 | +:meth:`~torchcodec.decoders.VideoDecoder.get_frames_at`, |
| 188 | +:meth:`~torchcodec.decoders.VideoDecoder.get_frames_in_range`, |
| 189 | +:meth:`~torchcodec.decoders.VideoDecoder.get_frames_played_at`, |
| 190 | +:meth:`~torchcodec.decoders.VideoDecoder.get_frames_played_in_range`. |
| 191 | +
|
174 | 192 | Args:
|
175 | 193 | index (int): The index of the frame to retrieve.
|
176 | 194 |
|
@@ -194,13 +212,6 @@ def get_frame_at(self, index: int) -> Frame:
|
194 | 212 | def get_frames_at(self, indices: list[int]) -> FrameBatch:
|
195 | 213 | """Return frames at the given indices.
|
196 | 214 |
|
197 |
| -.. note:: |
198 |
| -
|
199 |
| -Calling this method is more efficient that repeated individual calls |
200 |
| -to :meth:`~torchcodec.decoders.VideoDecoder.get_frame_at`. This |
201 |
| -method makes sure not to decode the same frame twice, and also |
202 |
| -avoids "backwards seek" operations, which are slow. |
203 |
| -
|
204 | 215 | Args:
|
205 | 216 | indices (list of int): The indices of the frames to retrieve.
|
206 | 217 |
|
@@ -252,6 +263,15 @@ def get_frames_in_range(self, start: int, stop: int, step: int = 1) -> FrameBatc
|
252 | 263 | def get_frame_played_at(self, seconds: float) -> Frame:
|
253 | 264 | """Return a single frame played at the given timestamp in seconds.
|
254 | 265 |
|
| 266 | +.. note:: |
| 267 | +
|
| 268 | +If you need to decode multiple frames, we recommend using the batch |
| 269 | +methods instead, since they are faster: |
| 270 | +:meth:`~torchcodec.decoders.VideoDecoder.get_frames_at`, |
| 271 | +:meth:`~torchcodec.decoders.VideoDecoder.get_frames_in_range`, |
| 272 | +:meth:`~torchcodec.decoders.VideoDecoder.get_frames_played_at`, |
| 273 | +:meth:`~torchcodec.decoders.VideoDecoder.get_frames_played_in_range`. |
| 274 | +
|
255 | 275 | Args:
|
256 | 276 | seconds (float): The time stamp in seconds when the frame is played.
|
257 | 277 |
|
@@ -276,13 +296,6 @@ def get_frame_played_at(self, seconds: float) -> Frame:
|
276 | 296 | def get_frames_played_at(self, seconds: list[float]) -> FrameBatch:
|
277 | 297 | """Return frames played at the given timestamps in seconds.
|
278 | 298 |
|
279 |
| -.. note:: |
280 |
| -
|
281 |
| -Calling this method is more efficient that repeated individual calls |
282 |
| -to :meth:`~torchcodec.decoders.VideoDecoder.get_frame_played_at`. |
283 |
| -This method makes sure not to decode the same frame twice, and also |
284 |
| -avoids "backwards seek" operations, which are slow. |
285 |
| -
|
286 | 299 | Args:
|
287 | 300 | seconds (list of float): The timestamps in seconds when the frames are played.
|
288 | 301 |
|
|
0 commit comments