Unverified Commit 36daee3f authored by Bruno Korbar's avatar Bruno Korbar Committed by GitHub
Browse files

[videoAPI] minor example and documentation changes (#2821)



* Modified the example to conform with the new DICT return.

* adding better stream documentation to examples

* Clearing up some documentation as a result of a feedback

* Formatting mostly

* Addressing Victor's comments.

* addressing fmassas comments

* remove unnecessary tab
Co-authored-by: default avatarBruno Korbar <korbar@vggdev9.vggdev.cluster>
Co-authored-by: default avatarvfdev <vfdev.5@gmail.com>
parent dc5d0554
This diff is collapsed.
......@@ -31,9 +31,13 @@ from .image import (
if _HAS_VIDEO_OPT:
def _has_video_opt():
return True
else:
def _has_video_opt():
return False
......@@ -91,15 +95,24 @@ class VideoReader:
def __init__(self, path, stream="video"):
if not _has_video_opt():
raise RuntimeError("Not compiled with video_reader support")
raise RuntimeError(
"Not compiled with video_reader support, "
+ "to enable video_reader support, please install "
+ "ffmpeg (version 4.2 is currently supported) and"
+ "build torchvision from source."
)
self._c = torch.classes.torchvision.Video(path, stream)
def __next__(self):
"""Decodes and returns the next frame of the current stream
"""Decodes and returns the next frame of the current stream.
Frames are encoded as a dict with mandatory
data and pts fields, where data is a tensor, and pts is a
presentation timestamp of the frame expressed in seconds
as a float.
Returns:
(dict): a dictionary with fields ``data`` and ``pts``
containing decoded frame and corresponding timestamp
(dict): a dictionary and containing decoded frame (``data``)
and corresponding timestamp (``pts``) in seconds
"""
frame, pts = self._c.next()
......
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