:orphan:

.. _gallery:

Interactive examples
====================



.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="TorchCodec can use supported Nvidia hardware (see support matrix here) to speed-up video decoding. This is called &quot;CUDA Decoding&quot; and it uses Nvidia&#x27;s NVDEC hardware decoder and CUDA kernels to respectively decompress and convert to RGB. CUDA Decoding can be faster than CPU Decoding for the actual decoding step and also for subsequent transform steps like scaling, cropping or rotating. This is because the decode step leaves the decoded tensor in GPU memory so the GPU doesn&#x27;t have to fetch from main memory before running the transform steps. Encoded packets are often much smaller than decoded frames so CUDA decoding also uses less PCI-e bandwidth.">

.. only:: html

  .. image:: /generated_examples/images/thumb/sphx_glr_basic_cuda_example_thumb.png
    :alt:

  :ref:`sphx_glr_generated_examples_basic_cuda_example.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Accelerated video decoding on GPUs with CUDA and NVDEC</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="In this example, we&#x27;ll learn how to decode a video using the VideoDecoder class.">

.. only:: html

  .. image:: /generated_examples/images/thumb/sphx_glr_basic_example_thumb.png
    :alt:

  :ref:`sphx_glr_generated_examples_basic_example.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Decoding a video with VideoDecoder</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="In this example, we&#x27;ll learn how to sample video clips from a video. A clip generally denotes a sequence or batch of frames, and is typically passed as input to video models.">

.. only:: html

  .. image:: /generated_examples/images/thumb/sphx_glr_sampling_thumb.png
    :alt:

  :ref:`sphx_glr_generated_examples_sampling.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">How to sample video clips</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="In this example, we will describe the seek_mode parameter of the VideoDecoder class. This parameter offers a trade-off between the speed of the VideoDecoder creation, against the seeking accuracy of the retreived frames (i.e. in approximate mode, requesting the i&#x27;th frame may not necessarily return frame i).">

.. only:: html

  .. image:: /generated_examples/images/thumb/sphx_glr_approximate_mode_thumb.png
    :alt:

  :ref:`sphx_glr_generated_examples_approximate_mode.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Exact vs Approximate seek mode: Performance and accuracy comparison</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /generated_examples/basic_cuda_example
   /generated_examples/basic_example
   /generated_examples/sampling
   /generated_examples/approximate_mode


.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-gallery

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download all examples in Python source code: generated_examples_python.zip </generated_examples/generated_examples_python.zip>`

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download all examples in Jupyter notebooks: generated_examples_jupyter.zip </generated_examples/generated_examples_jupyter.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_