Skip to content

Commit b90b99e

Browse files
committed
Merge branch 'main' of github.com:pytorch/torchcodec into new-theme
2 parents 2fca77d + 7945e6a commit b90b99e

22 files changed

+372
-66
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.rst

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ torchcodec.decoders
2828
.. currentmodule:: torchcodec.decoders
2929

3030

31-
For a video decoder tutorial, see: :ref:`sphx_glr_generated_examples_basic_example.py`.
32-
For an audio decoder tutorial, see: :ref:`sphx_glr_generated_examples_audio_decoding.py`.
31+
For a video decoder tutorial, see: :ref:`sphx_glr_generated_examples_decoding_basic_example.py`.
32+
For an audio decoder tutorial, see: :ref:`sphx_glr_generated_examples_decoding_audio_decoding.py`.
3333

3434

3535
.. autosummary::
@@ -49,6 +49,25 @@ For an audio decoder tutorial, see: :ref:`sphx_glr_generated_examples_audio_deco
4949
VideoStreamMetadata
5050
AudioStreamMetadata
5151

52+
.. _encoders:
53+
54+
torchcodec.encoders
55+
-------------------
56+
57+
.. currentmodule:: torchcodec.encoders
58+
59+
60+
For an audio decoder tutorial, see: :ref:`sphx_glr_generated_examples_encoding_audio_encoding.py`.
61+
62+
63+
.. autosummary::
64+
:toctree: generated/
65+
:nosignatures:
66+
:template: class.rst
67+
68+
AudioEncoder
69+
70+
5271
.. _samplers:
5372

5473
torchcodec.samplers
@@ -57,7 +76,7 @@ torchcodec.samplers
5776

5877
.. currentmodule:: torchcodec.samplers
5978

60-
For a tutorial, see: :ref:`sphx_glr_generated_examples_sampling.py`.
79+
For a tutorial, see: :ref:`sphx_glr_generated_examples_decoding_sampling.py`.
6180

6281
.. autosummary::
6382
:toctree: generated/

docs/source/conf.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,27 @@ class CustomGalleryExampleSortKey:
7272
def __init__(self, src_dir):
7373
self.src_dir = src_dir
7474

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

docs/source/index.rst

Lines changed: 35 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: Installation

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.
File renamed without changes.

examples/file_like.py renamed to examples/decoding/file_like.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def bench(f, average_over=10, warmup=2):
9696
# the :class:`~torchcodec.decoders.VideoDecoder` class to ``"approximate"``. We do
9797
# this to avoid scanning the entire video during initialization, which would
9898
# require downloading the entire video even if we only want to decode the first
99-
# frame. See :ref:`sphx_glr_generated_examples_approximate_mode.py` for more.
99+
# frame. See :ref:`sphx_glr_generated_examples_decoding_approximate_mode.py` for more.
100100

101101

102102
def decode_from_existing_download():

0 commit comments

Comments
 (0)