Commit 63244623 authored by moto's avatar moto Committed by Facebook GitHub Bot
Browse files

Extract NVDEC tutorial from the current notebook (#3478)

Summary:
Now that GPU video decoders are available in doc CI, we run the tutorials with GPU decoders.

Pull Request resolved: https://github.com/pytorch/audio/pull/3478

Differential Revision: D47519672

Pulled By: mthrok

fbshipit-source-id: 2f95243100e9c75e17c2b4d306da164f0e31f8f2
parent 44b92062
.. _enabling_hw_decoder:
Enabling GPU video decoder/encoder
==================================
......@@ -379,7 +381,7 @@ The following command fetches video from remote server, decode with NVDEC (cuvid
-b:v 5M test.mp4
Note that there is ``Stream #0:0 -> #0:0 (h264 (h264_cuvid) -> h264 (h264_nvenc))``, which means that video is decoded with ``h264_cuvid`` decoder and ``h264_nvenc`` encoder.
.. code-block::
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'https://download.pytorch.org/torchaudio/tutorial-assets/stream-api/NASAs_Most_Scientifically_Complex_Space_Observatory_Requires_Precision-MP4_small.mp4':
......@@ -468,28 +470,4 @@ Using the hardware decoder
Once the installation and the runtime linking work fine, then you can test the GPU decoding with the following.
For the detail on the performance of GPU decoder and encoder please see `Hardware-Accelerated Video Decoding and Encoding <./hw_acceleration_tutorial.html>`_
.. code-block:: python
from torchaudio.io import StreamReader
src = "https://download.pytorch.org/torchaudio/tutorial-assets/stream-api/NASAs_Most_Scientifically_Complex_Space_Observatory_Requires_Precision-MP4_small.mp4"
s = StreamReader(src)
s.add_video_stream(
5,
decoder="h264_cuvid",
hw_accel="cuda:0",
decoder_option={
"resize": "360x240",
},
)
s.fill_buffer()
chunk, = s.pop_chunks()
print(' - Chunk:', chunk.shape, chunk.device, chunk.dtype)
.. code-block:: text
- Chunk: torch.Size([5, 3, 240, 360]) cuda:0 torch.uint8
For the detail on the performance of GPU decoder please see :ref:`NVDEC tutoial <nvdec_tutorial>`.
......@@ -45,6 +45,7 @@ model implementations and application components.
tutorials/streamwriter_basic_tutorial
tutorials/streamwriter_advanced
hw_acceleration_tutorial
tutorials/nvdec_tutorial
tutorials/effector_tutorial
tutorials/audio_resampling_tutorial
......@@ -194,6 +195,13 @@ Tutorials
:link: tutorials/streamwriter_advanced.html
:tags: I/O,StreamWriter
.. customcarditem::
:header: Hardware accelerated video decoding with NVDEC
:card_description: Learn how to use HW video decoder.
:image: https://download.pytorch.org/torchaudio/tutorial-assets/thumbnails/hw_acceleration_tutorial.png
:link: tutorials/nvdec_tutorial.html
:tags: I/O,StreamReader
.. customcarditem::
:header: Hardware accelerated video I/O with NVDEC/NVENC
:card_description: Learn how to setup and use HW accelerated video I/O.
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment