Skip to content

Commit 29866fc

Browse files
committed
Merge branch 'main' of github.com:pytorch/torchcodec into avio
2 parents 2954c9b + 6ab09a8 commit 29866fc

File tree

14 files changed

+421
-46
lines changed

14 files changed

+421
-46
lines changed

.github/workflows/linux_wheel.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ jobs:
104104
105105
- name: Install test dependencies
106106
run: |
107-
python -m pip install --pre torchvision --index-url https://download.pytorch.org/whl/nightly/cpu
108107
# Ideally we would find a way to get those dependencies from pyproject.toml
109108
python -m pip install numpy pytest pillow
110109

.github/workflows/macos_wheel.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ jobs:
103103
104104
- name: Install test dependencies
105105
run: |
106-
python -m pip install --pre torchvision --index-url https://download.pytorch.org/whl/nightly/cpu
107106
python -m pip install numpy pytest pillow
108107
109108
- name: Delete the src/ folder just for fun

.github/workflows/reference_resources.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
run: |
4343
# Note that we're installing stable - this is for running a script where we're a normal PyTorch
4444
# user, not for building TorhCodec.
45-
python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
45+
python -m pip install torch --index-url https://download.pytorch.org/whl/cpu
4646
python -m pip install numpy pillow
4747
4848
- name: Check out repo

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pip install -e ".[dev]" --no-build-isolation -vv
4848

4949
### Running unit tests
5050

51-
To run python tests run (please make sure `torchvision` is installed):
51+
To run python tests run:
5252

5353
```bash
5454
pytest test -vvv

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
# TorchCodec
44

5-
TorchCodec is a Python library for decoding videos into PyTorch tensors, on CPU
6-
and CUDA GPU. It aims to be fast, easy to use, and well integrated into the
7-
PyTorch ecosystem. If you want to use PyTorch to train ML models on videos,
8-
TorchCodec is how you turn those videos into data.
5+
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.
99

1010
We achieve these capabilities through:
1111

docs/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ sphinx-tabs
66
matplotlib
77
torchvision
88
ipython
9+
fsspec
10+
aiohttp
911
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme

docs/source/conf.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,44 @@
5757
"sphinx_copybutton",
5858
]
5959

60+
61+
class CustomGalleryExampleSortKey:
62+
# This class defines the order in which our examples appear in
63+
# https://pytorch.org/torchcodec/stable/generated_examples/index.html
64+
# They would otherwise be sorted alphabetically.
65+
#
66+
# See https://sphinx-gallery.github.io/stable/configuration.html#sorting-gallery-examples
67+
# and https://github.com/sphinx-gallery/sphinx-gallery/blob/master/sphinx_gallery/sorting.py
68+
def __init__(self, src_dir):
69+
self.src_dir = src_dir
70+
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+
80+
def __call__(self, filename):
81+
try:
82+
return self.order.index(filename)
83+
except ValueError as e:
84+
raise ValueError(
85+
"Looks like you added an example in the examples/ folder?"
86+
"You need to specify its order in docs/source/conf.py. Look for CustomGalleryExampleSortKey."
87+
) from e
88+
89+
6090
sphinx_gallery_conf = {
6191
"examples_dirs": "../../examples/", # path to your example scripts
6292
"gallery_dirs": "generated_examples", # path to where to save gallery generated output
6393
"filename_pattern": ".py",
6494
"backreferences_dir": "gen_modules/backreferences",
6595
"doc_module": ("torchcodec",),
6696
"remove_config_comments": True,
97+
"within_subsection_order": CustomGalleryExampleSortKey,
6798
}
6899

69100
# We override sphinx-gallery's example header to prevent sphinx-gallery from

docs/source/index.rst

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Welcome to the TorchCodec documentation!
22
========================================
33

4-
TorchCodec is a Python library for decoding videos into PyTorch tensors, on CPU
5-
and CUDA GPU. It aims to be fast, easy to use, and well integrated into the
6-
PyTorch ecosystem. If you want to use PyTorch to train ML models on videos,
7-
TorchCodec is how you turn those videos into data.
4+
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.
88

99
We achieve these capabilities through:
1010

@@ -36,12 +36,12 @@ We achieve these capabilities through:
3636
A simple video decoding example
3737

3838
.. grid-item-card:: :octicon:`file-code;1em`
39-
Clip sampling
39+
Audio Decoding
4040
:img-top: _static/img/card-background.svg
41-
:link: generated_examples/sampling.html
41+
:link: generated_examples/audio_decoding.html
4242
:link-type: url
4343

44-
How to sample regular and random clips from a video
44+
A simple audio decoding example
4545

4646
.. grid-item-card:: :octicon:`file-code;1em`
4747
GPU decoding
@@ -51,6 +51,22 @@ We achieve these capabilities through:
5151

5252
A simple example demonstrating CUDA GPU decoding
5353

54+
.. grid-item-card:: :octicon:`file-code;1em`
55+
Streaming video
56+
:img-top: _static/img/card-background.svg
57+
:link: generated_examples/file_like.html
58+
:link-type: url
59+
60+
How to efficiently decode videos from the cloud
61+
62+
.. grid-item-card:: :octicon:`file-code;1em`
63+
Clip sampling
64+
:img-top: _static/img/card-background.svg
65+
:link: generated_examples/sampling.html
66+
:link-type: url
67+
68+
How to sample regular and random clips from a video
69+
5470
.. note::
5571

5672
TorchCodec is still in development stage and we are actively seeking

examples/basic_example.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ def plot(frames: torch.Tensor, title : Optional[str] = None):
9393
# :class:`~torchcodec.decoders.VideoDecoder`. Frames are always of
9494
# ``torch.uint8`` dtype.
9595
#
96+
# .. note::
97+
#
98+
# If you need to decode multiple frames, we recommend using the batch
99+
# methods instead, since they are faster:
100+
# :meth:`~torchcodec.decoders.VideoDecoder.get_frames_at`,
101+
# :meth:`~torchcodec.decoders.VideoDecoder.get_frames_in_range`,
102+
# :meth:`~torchcodec.decoders.VideoDecoder.get_frames_played_at`, and
103+
# :meth:`~torchcodec.decoders.VideoDecoder.get_frames_played_in_range`. They
104+
# are described below.
105+
96106

97107
plot(first_frame, "First frame")
98108

0 commit comments

Comments
 (0)