Skip to content

Commit 3d74528

Browse files
committed
addressed comments
1 parent 3304341 commit 3d74528

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

.github/workflows/docs.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ jobs:
5353
# 3.9 corresponds to the minimum python version for which we build
5454
# the wheel unless the label cliflow/binaries/all is present in the
5555
# PR.
56-
# For the actual release we should add that label and change this to
57-
# include more python versions.
5856
python-version: ['3.9']
5957
cuda-version: ['12.4']
6058
ffmpeg-version-for-tests: ['7']

docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ We achieve these capabilities through:
5656
:link: generated_examples/basic_cuda_example.html
5757
:link-type: url
5858

59-
A simple example demonstrating Nvidia GPU decoding
59+
A simple example demonstrating CUDA GPU decoding
6060

6161
.. toctree::
6262
:maxdepth: 1

examples/basic_cuda_example.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
Accelerated video decoding on GPUs with CUDA and NVDEC
88
================================================================
99
10-
.. _ndecoderec_tutorial:
11-
1210
TorchCodec can use supported Nvidia hardware (see support matrix
1311
`here <https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new>`_) to speed-up
1412
video decoding. This is called "CUDA Decoding" and it uses Nvidia's
@@ -45,12 +43,15 @@
4543
#. An Nvidia GPU that supports decoding the video format you want to decode. See
4644
the support matrix `here <https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new>`_
4745
#. `CUDA-enabled pytorch <https://pytorch.org/get-started/locally/>`_
48-
#. FFmpeg binaries that support NdecoderEC-enabled codecs
46+
#. FFmpeg binaries that support
47+
`NVDEC-enabled <https://docs.nvidia.com/video-technologies/video-codec-sdk/12.0/ffmpeg-with-nvidia-gpu/index.html>`_
48+
codecs
4949
#. libnpp and nvrtc (these are usually installed when you install the full cuda-toolkit)
5050
5151
52-
FFmpeg versions 5, 6 and 7 from conda-forge are built with NdecoderEC support and you can
53-
install them with conda. For example, to install FFmpeg version 7:
52+
FFmpeg versions 5, 6 and 7 from conda-forge are built with
53+
`NVDEC support <https://docs.nvidia.com/video-technologies/video-codec-sdk/12.0/ffmpeg-with-nvidia-gpu/index.html>`_
54+
and you can install them with conda. For example, to install FFmpeg version 7:
5455
5556
5657
.. code-block:: bash
@@ -117,7 +118,7 @@
117118
#
118119
# The video frames are decoded and returned as tensor of NCHW format.
119120

120-
print(frame.data.shape, frame.data.dtype)
121+
print(frame.shape, frame.dtype)
121122

122123
# %%
123124
#
@@ -132,23 +133,22 @@
132133
#
133134
# Let's look at the frames decoded by CUDA decoder and compare them
134135
# against equivalent results from the CPU decoders.
135-
import matplotlib.pyplot as plt
136-
from torchvision.transforms.v2.functional import to_pil_image
137-
138-
139-
def get_frames(timestamps: list[float], device: str):
140-
decoder = VideoDecoder(video_file, device=device)
141-
return [decoder.get_frame_played_at(ts).data for ts in timestamps]
142-
143-
144136
timestamps = [12, 19, 45, 131, 180]
145-
cpu_frames = get_frames(timestamps, device="cpu")
146-
cuda_frames = get_frames(timestamps, device="cuda")
137+
cpu_decoder = VideoDecoder(video_file, device="cpu")
138+
cuda_decoder = VideoDecoder(video_file, device="cuda")
139+
cpu_frames = cpu_decoder.get_frames_played_at(timestamps).data
140+
cuda_frames = cuda_decoder.get_frames_played_at(timestamps).data
147141

148142

149143
def plot_cpu_and_cuda_frames(
150144
cpu_frames: list[torch.Tensor], cuda_frames: list[torch.Tensor]
151145
):
146+
try:
147+
import matplotlib.pyplot as plt
148+
from torchvision.transforms.v2.functional import to_pil_image
149+
except ImportError:
150+
print("Cannot plot, please run `pip install torchvision matplotlib`")
151+
return
152152
n_rows = len(timestamps)
153153
fig, axes = plt.subplots(n_rows, 2, figsize=[12.8, 16.0])
154154
for i in range(n_rows):

0 commit comments

Comments
 (0)