Skip to main content

VideoSource

Brings data from a video source, decodes the frames and creates the metadata.

This module contains the video source. It is responsible for connecting to video sources, decoding the video, and creating the video frames. Frames are then attached to the metadata which is passed to the first element in the pipeline.

Along with the standard source paramters address, rate and type, there are two additional parameters:

  • timeout (int): if source is disconnected try to reconnect for this many minutes, -1 is try indefinitely
  • proxy (bool): whether to enable MP4 proxying of video stream

The default timeout is -1, the default proxy is True.

There are three different types that the video source supports:

  • video: A video source that is a rtsp or http stream.
  • youtube: A video source that is a YouTube video.
  • file: A video source that is a local file.

Examples:

REST API:

WIP

Configuration File:

YouTube video:

source:
- address: https://youtu.be/jY86pXeTOLw
- type: youtube

RSTP video at 15 fps:

source:
- address: rtsp://camera:554/path
- type: video
- rate: 15

HTTPS video attempt to reconnect for 10 minutes:

source:
- address: https://camera:554/path
- type: video
- timeout: 10

Local file disable proxy:

source:
- address: /path/to/file.mp4
- type: file
- proxy: false

VideoSource Objects

class VideoSource(Source)

Brings data from a video source, decodes the frames and creates the metadata.

Attributes:

  • source_type str - The type of the video source.
  • source_address str - The address of the video source.
  • source_fps float - The frames per second of the video source.
  • source_gst str - The GStreamer pipeline to use.
  • proxy Optional[Tuple[ProxyManager, str]] - The proxy manager and the proxy name.
  • timeout float - The timeout in minutes to attempt to reconnect.

Examples:

source_url = "rtsp://camera:554/path"
gst_string = (
f"rtspsrc location={source_url} latency=0 buffer-mode=auto ! rtph264depay"
f" ! h264parse ! avdec_h264 ! videoconvert ! videorate "
f"! video/x-raw,framerate=30/1,format=RGB ! appsink sync=true"
)
vs = VideoSource("video", source_url, 30, gst_string, False)