Skip to content

Commit 9bbeb1f

Browse files
committed
adjust docstirngs, apply nits
1 parent 3eaee28 commit 9bbeb1f

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

examples/encoding/video_encoding.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,6 @@ def play_video(encoded_bytes):
155155
)
156156
print(f"Codec used in {name}: {result.stdout.strip()}")
157157

158-
# %%
159-
# For most cases, you can simply specify the format parameter and let the FFmpeg select the default codec.
160-
# However, specifying the codec parameter is useful to select a particular codec implementation
161-
# (``libx264`` vs ``libx265``) or to have more control over the encoding behavior.
162158

163159
# %%
164160
# .. _pixel_format:
@@ -199,7 +195,7 @@ def play_video(encoded_bytes):
199195
# For example, with the commonly used H.264 codec, ``libx264``:
200196
#
201197
# - Values range from 0 (lossless) to 51 (worst quality)
202-
# - Values 17 or 18 are conisdered visually lossless, and the default is 23.
198+
# - Values 17 or 18 are considered visually lossless, and the default is 23.
203199
#
204200
# .. note::
205201
#
@@ -228,10 +224,11 @@ def play_video(encoded_bytes):
228224
# Faster presets encode faster but produce larger files, while slower
229225
# presets take more time to encode but result in better compression.
230226
#
231-
# For example, with the commonly used H.264 codec, ``libx264`` presets include:
232-
#
233-
# - ``"ultrafast"`` (fastest), ``"fast"``, ``"medium"`` (default), ``"slow"``, ``"veryslow"`` (slowest, best compression).
234-
# - See additional details in the `H.264 Video Encoding Guide <https://trac.ffmpeg.org/wiki/Encode/H.264#a2.Chooseapresetandtune>`_.
227+
# For example, with the commonly used H.264 codec, ``libx264`` presets include
228+
# ``"ultrafast"`` (fastest), ``"fast"``, ``"medium"`` (default), ``"slow"``, and
229+
# ``"veryslow"`` (slowest, best compression). See the
230+
# `H.264 Video Encoding Guide <https://trac.ffmpeg.org/wiki/Encode/H.264#a2.Chooseapresetandtune>`_
231+
# for additional details.
235232
#
236233
# .. note::
237234
#
@@ -272,13 +269,12 @@ def play_video(encoded_bytes):
272269
#
273270

274271

275-
# Custom GOP size and tuning
276272
custom_output = tempfile.NamedTemporaryFile(suffix=".mp4", delete=False).name
277273
encoder.to_file(
278274
custom_output,
279275
codec="libx264",
280276
extra_options={
281-
"g": 50, # Keyframe every 50 frames
277+
"g": 50, # Keyframe every 50 frames
282278
"max_b_frames": 0, # Disable B-frames for faster decoding
283279
"tune": "fastdecode", # Optimize for fast decoding
284280
}

src/torchcodec/encoders/_video_encoder.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,16 @@ def to_file(
5656
"yuv420p", "yuv444p"). If not specified, uses codec's default format.
5757
See :ref:`pixel_format` for details.
5858
crf (int or float, optional): Constant Rate Factor for encoding quality. Lower values
59-
mean better quality. Valid range depends on the encoder (commonly 0-51).
59+
mean better quality. Valid range depends on the encoder (e.g. 0-51 for libx264).
6060
Defaults to None (which will use encoder's default).
6161
See :ref:`crf` for details.
6262
preset (str or int, optional): Encoder option that controls the tradeoff between
63-
encoding speed and compression. Valid values depend on the encoder (commonly
63+
encoding encoding speed and compression (output size). Valid on the encoder (commonly
6464
a string: "fast", "medium", "slow"). Defaults to None
6565
(which will use encoder's default).
6666
See :ref:`preset` for details.
6767
extra_options (dict[str, Any], optional): A dictionary of additional
6868
encoder options to pass, e.g. ``{"qp": 5, "tune": "film"}``.
69-
Values will be converted to strings before passing to the encoder.
7069
See :ref:`extra_options` for details.
7170
"""
7271
preset = str(preset) if isinstance(preset, int) else preset
@@ -106,17 +105,16 @@ def to_tensor(
106105
"yuv420p", "yuv444p"). If not specified, uses codec's default format.
107106
See :ref:`pixel_format` for details.
108107
crf (int or float, optional): Constant Rate Factor for encoding quality. Lower values
109-
mean better quality. Valid range depends on the encoder (commonly 0-51).
108+
mean better quality. Valid range depends on the encoder (e.g. 0-51 for libx264).
110109
Defaults to None (which will use encoder's default).
111110
See :ref:`crf` for details.
112111
preset (str or int, optional): Encoder option that controls the tradeoff between
113-
encoding speed and compression. Valid values depend on the encoder (commonly
112+
encoding encoding speed and compression (output size). Valid on the encoder (commonly
114113
a string: "fast", "medium", "slow"). Defaults to None
115114
(which will use encoder's default).
116115
See :ref:`preset` for details.
117116
extra_options (dict[str, Any], optional): A dictionary of additional
118117
encoder options to pass, e.g. ``{"qp": 5, "tune": "film"}``.
119-
Values will be converted to strings before passing to the encoder.
120118
See :ref:`extra_options` for details.
121119
122120
Returns:
@@ -165,17 +163,16 @@ def to_file_like(
165163
"yuv420p", "yuv444p"). If not specified, uses codec's default format.
166164
See :ref:`pixel_format` for details.
167165
crf (int or float, optional): Constant Rate Factor for encoding quality. Lower values
168-
mean better quality. Valid range depends on the encoder (commonly 0-51).
166+
mean better quality. Valid range depends on the encoder (e.g. 0-51 for libx264).
169167
Defaults to None (which will use encoder's default).
170168
See :ref:`crf` for details.
171169
preset (str or int, optional): Encoder option that controls the tradeoff between
172-
encoding speed and compression. Valid values depend on the encoder (commonly
170+
encoding encoding speed and compression (output size). Valid on the encoder (commonly
173171
a string: "fast", "medium", "slow"). Defaults to None
174172
(which will use encoder's default).
175173
See :ref:`preset` for details.
176174
extra_options (dict[str, Any], optional): A dictionary of additional
177175
encoder options to pass, e.g. ``{"qp": 5, "tune": "film"}``.
178-
Values will be converted to strings before passing to the encoder.
179176
See :ref:`extra_options` for details.
180177
"""
181178
preset = str(preset) if isinstance(preset, int) else preset

0 commit comments

Comments
 (0)