Skip to content

Commit 7945e6a

Browse files
authored
Add Docs for AudioEncoder (#717)
1 parent ffb65f6 commit 7945e6a

21 files changed

+243
-48
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33
# TorchCodec
44

55
TorchCodec is a Python library for decoding video and audio data into PyTorch
6-
tensors, on CPU and CUDA GPU. It aims to be fast, easy to use, and well
7-
integrated into the PyTorch ecosystem. If you want to use PyTorch to train ML
8-
models on videos and audio, TorchCodec is how you turn these into data.
6+
tensors, on CPU and CUDA GPU. It also supports audio encoding, and video
7+
encoding will come soon! It aims to be fast, easy to use, and well integrated
8+
into the PyTorch ecosystem. If you want to use PyTorch to train ML models on
9+
videos and audio, TorchCodec is how you turn these into data.
910

1011
We achieve these capabilities through:
1112

1213
* Pythonic APIs that mirror Python and PyTorch conventions.
13-
* Relying on [FFmpeg](https://www.ffmpeg.org/) to do the decoding. TorchCodec
14-
uses the version of FFmpeg you already have installed. FFmpeg is a mature
15-
library with broad coverage available on most systems. It is, however, not
16-
easy to use. TorchCodec abstracts FFmpeg's complexity to ensure it is used
14+
* Relying on [FFmpeg](https://www.ffmpeg.org/) to do the decoding and encoding.
15+
TorchCodec uses the version of FFmpeg you already have installed. FFmpeg is a
16+
mature library with broad coverage available on most systems. It is, however,
17+
not easy to use. TorchCodec abstracts FFmpeg's complexity to ensure it is used
1718
correctly and efficiently.
1819
* Returning data as PyTorch tensors, ready to be fed into PyTorch transforms
1920
or used directly to train models.

docs/source/api_ref_decoders.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ torchcodec.decoders
77
.. currentmodule:: torchcodec.decoders
88

99

10-
For a video decoder tutorial, see: :ref:`sphx_glr_generated_examples_basic_example.py`.
11-
For an audio decoder tutorial, see: :ref:`sphx_glr_generated_examples_audio_decoding.py`.
10+
For a video decoder tutorial, see: :ref:`sphx_glr_generated_examples_decoding_basic_example.py`.
11+
For an audio decoder tutorial, see: :ref:`sphx_glr_generated_examples_decoding_audio_decoding.py`.
1212

1313

1414
.. autosummary::

docs/source/api_ref_encoders.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.. _encoders:
2+
3+
===================
4+
torchcodec.encoders
5+
===================
6+
7+
.. currentmodule:: torchcodec.encoders
8+
9+
10+
For an audio decoder tutorial, see: :ref:`sphx_glr_generated_examples_encoding_audio_encoding.py`.
11+
12+
13+
.. autosummary::
14+
:toctree: generated/
15+
:nosignatures:
16+
:template: class.rst
17+
18+
AudioEncoder

docs/source/api_ref_samplers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ torchcodec.samplers
66

77
.. currentmodule:: torchcodec.samplers
88

9-
For a tutorial, see: :ref:`sphx_glr_generated_examples_sampling.py`.
9+
For a tutorial, see: :ref:`sphx_glr_generated_examples_decoding_sampling.py`.
1010

1111
.. autosummary::
1212
:toctree: generated/

docs/source/conf.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,27 @@ class CustomGalleryExampleSortKey:
6868
def __init__(self, src_dir):
6969
self.src_dir = src_dir
7070

71-
order = [
72-
"basic_example.py",
73-
"audio_decoding.py",
74-
"basic_cuda_example.py",
75-
"file_like.py",
76-
"approximate_mode.py",
77-
"sampling.py",
78-
]
79-
8071
def __call__(self, filename):
72+
# We have two top-level galleries, one for decoding examples and one for
73+
# encoding examples. We define the example order within each gallery
74+
# individually.
75+
if "examples/decoding" in self.src_dir:
76+
order = [
77+
"basic_example.py",
78+
"audio_decoding.py",
79+
"basic_cuda_example.py",
80+
"file_like.py",
81+
"approximate_mode.py",
82+
"sampling.py",
83+
]
84+
else:
85+
assert "examples/encoding" in self.src_dir
86+
order = [
87+
"audio_encoding.py",
88+
]
89+
8190
try:
82-
return self.order.index(filename)
91+
return order.index(filename)
8392
except ValueError as e:
8493
raise ValueError(
8594
"Looks like you added an example in the examples/ folder?"

docs/source/index.rst

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,25 @@ Welcome to the TorchCodec documentation!
22
========================================
33

44
TorchCodec is a Python library for decoding video and audio data into PyTorch
5-
tensors, on CPU and CUDA GPU. It aims to be fast, easy to use, and well
6-
integrated into the PyTorch ecosystem. If you want to use PyTorch to train ML
7-
models on videos and audio, TorchCodec is how you turn these into data.
5+
tensors, on CPU and CUDA GPU. It also supports audio encoding, and video encoding will come soon!
6+
It aims to be fast, easy to use, and well integrated into the PyTorch ecosystem.
7+
If you want to use PyTorch to train ML models on videos and audio, TorchCodec is
8+
how you turn these into data.
89

910
We achieve these capabilities through:
1011

1112
* Pythonic APIs that mirror Python and PyTorch conventions.
12-
* Relying on `FFmpeg <https://www.ffmpeg.org/>`_ to do the decoding. TorchCodec
13-
uses the version of FFmpeg you already have installed. FMPEG is a mature
14-
library with broad coverage available on most systems. It is, however, not
15-
easy to use. TorchCodec abstracts FFmpeg's complexity to ensure it is used
16-
correctly and efficiently.
13+
* Relying on `FFmpeg <https://www.ffmpeg.org/>`_ to do the decoding / encoding.
14+
TorchCodec uses the version of FFmpeg you already have installed. FMPEG is a
15+
mature library with broad coverage available on most systems. It is, however,
16+
not easy to use. TorchCodec abstracts FFmpeg's complexity to ensure it is
17+
used correctly and efficiently.
1718
* Returning data as PyTorch tensors, ready to be fed into PyTorch transforms
1819
or used directly to train models.
1920

21+
Installation instructions
22+
^^^^^^^^^^^^^^^^^^^^^^^^^
23+
2024
.. grid:: 3
2125

2226
.. grid-item-card:: :octicon:`file-code;1em`
@@ -27,46 +31,64 @@ We achieve these capabilities through:
2731

2832
How to install TorchCodec
2933

34+
Decoding
35+
^^^^^^^^
36+
37+
.. grid:: 3
38+
3039
.. grid-item-card:: :octicon:`file-code;1em`
3140
Getting Started with TorchCodec
3241
:img-top: _static/img/card-background.svg
33-
:link: generated_examples/basic_example.html
42+
:link: generated_examples/decoding/basic_example.html
3443
:link-type: url
3544

3645
A simple video decoding example
3746

3847
.. grid-item-card:: :octicon:`file-code;1em`
3948
Audio Decoding
4049
:img-top: _static/img/card-background.svg
41-
:link: generated_examples/audio_decoding.html
50+
:link: generated_examples/decoding/audio_decoding.html
4251
:link-type: url
4352

4453
A simple audio decoding example
4554

4655
.. grid-item-card:: :octicon:`file-code;1em`
4756
GPU decoding
4857
:img-top: _static/img/card-background.svg
49-
:link: generated_examples/basic_cuda_example.html
58+
:link: generated_examples/decoding/basic_cuda_example.html
5059
:link-type: url
5160

5261
A simple example demonstrating CUDA GPU decoding
5362

5463
.. grid-item-card:: :octicon:`file-code;1em`
5564
Streaming video
5665
:img-top: _static/img/card-background.svg
57-
:link: generated_examples/file_like.html
66+
:link: generated_examples/decoding/file_like.html
5867
:link-type: url
5968

6069
How to efficiently decode videos from the cloud
6170

6271
.. grid-item-card:: :octicon:`file-code;1em`
6372
Clip sampling
6473
:img-top: _static/img/card-background.svg
65-
:link: generated_examples/sampling.html
74+
:link: generated_examples/decoding/sampling.html
6675
:link-type: url
6776

6877
How to sample regular and random clips from a video
6978

79+
Encoding
80+
^^^^^^^^
81+
82+
.. grid:: 3
83+
84+
.. grid-item-card:: :octicon:`file-code;1em`
85+
Audio Encoding
86+
:img-top: _static/img/card-background.svg
87+
:link: generated_examples/encoding/audio_encoding.html
88+
:link-type: url
89+
90+
How encode audio samples
91+
7092
.. toctree::
7193
:maxdepth: 1
7294
:caption: TorchCodec documentation
@@ -92,4 +114,5 @@ We achieve these capabilities through:
92114

93115
api_ref_torchcodec
94116
api_ref_decoders
117+
api_ref_encoders
95118
api_ref_samplers

examples/decoding/README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Decoding
2+
--------
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)