Skip to content

Commit daa33b6

Browse files
committed
Minor edits
1 parent cb544c2 commit daa33b6

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

examples/file_like.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ def direct_url_to_ffmpeg():
146146
# needed. Rather than implementing our own, we can use such objects from the
147147
# `fsspec <https://github.com/fsspec/filesystem_spec>`_ module that provides
148148
# `Filesystem interfaces for Python <https://filesystem-spec.readthedocs.io/en/latest/?badge=latest>`_.
149-
# Note that using these capabilities from the fsspec` library also requires the
149+
# Note that using these capabilities from the fsspec library also requires the
150150
# `aiohttp <https://docs.aiohttp.org/en/stable/>`_ module. You can install both with
151-
# ``pip install fsspec aiohttp``.
151+
# `pip install fsspec aiohttp`.
152152

153153
import fsspec
154154

@@ -251,21 +251,22 @@ def seek(self, offset: int, whence: int) -> bytes:
251251
#
252252
# It's also worth noting that the Python file-like interface is only half of
253253
# the story. FFmpeg also has its own mechanism for directing reads and seeks
254-
# during decoding to user-define functions. TorchCodec does the work of
254+
# during decoding to user-define functions. The
255+
# :class:`~torchcodec.decoders.VideoDecoder` object does the work of
255256
# connecting the Python methods you define to FFmpeg. All you have to do is
256-
# define your methods in Python, and TorchCodec handles the rest.
257+
# define your methods in Python, and we do the rest.
257258

258259
# %%
259260
# Performance: local file path vs. local file-like object
260261
# -------------------------------------------------------
261262
#
262263
# Since we have a local file defined, let's do a bonus performance test. We now
263-
# have two means of providing a local file to TorchCodec:
264+
# have two means of providing a local file to :class:`~torchcodec.decoders.VideoDecoder`:
264265
#
265-
# 1. Through a path, where TorchCodec will then do the work of opening the
266-
# local file at that path.
267-
# 2. Through a file-like object, where you open the file yourself and provide
268-
# the file-like object to TorchCodec.
266+
# 1. Through a *path*, where the :class:`~torchcodec.decoders.VideoDecoder`
267+
# object will then do the work of opening the local file at that path.
268+
# 2. Through a *file-like object*, where you open the file yourself and provide
269+
# the file-like object to :class:`~torchcodec.decoders.VideoDecoder`.
269270
#
270271
# An obvious question is: which is faster? The code below tests that question.
271272

@@ -276,8 +277,8 @@ def decode_from_existing_file_path():
276277

277278

278279
def decode_from_existing_open_file_object():
279-
with open(nasa_video_path, "rb") as f:
280-
decoder = VideoDecoder(f, seek_mode="approximate")
280+
with open(nasa_video_path, "rb") as file:
281+
decoder = VideoDecoder(file, seek_mode="approximate")
281282
return decoder[0]
282283

283284

0 commit comments

Comments
 (0)