Skip to content

Commit

Permalink
[torchcodec] Add a simple example showing how to decode the first fra…
Browse files Browse the repository at this point in the history
…me of a video (#51)

Summary: Pull Request resolved: #51

Differential Revision: D59022932
  • Loading branch information
ahmadsharif1 authored and facebook-github-bot committed Jun 25, 2024
1 parent d024e7b commit e863c06
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 34 deletions.
17 changes: 17 additions & 0 deletions examples/basic_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
=============
Basic Example to use TorchCodec to decode a video.
=============
"""

# A simple example showing how to decode the first few frames of a video.
# using the :class:`~torchcodec.decoders.SimpleVideoDecoder` class.
# %%
from torchcodec.decoders import SimpleVideoDecoder

video_file_path = __file__ + "../test/decoders/resources/nasa_13013.mp4"
simple_decoder = SimpleVideoDecoder(video_file_path)
num_frames = len(simple_decoder)
print("{video_file_path=} has {num_frames=} frames")
first_frame = simple_decoder[0]
print("{type(first_frame)=}")
34 changes: 0 additions & 34 deletions examples/basic_example_remove_me.py

This file was deleted.

0 comments on commit e863c06

Please sign in to comment.