Capturing a network video stream

How to enable this feature

Please see this page for the pre-requisites and pip install options needed to enable this feature.

Example with explanation

To start capturing a network video stream, we first obtain the GIFT-Grab video source factory singleton:

from pygiftgrab import VideoSourceFactory
sfac = VideoSourceFactory.get_instance()

Then we request a connection to our network source using the obtained factory:

from pygiftgrab import ColourSpace
source_mrl = 'rtsp://192.168.127.191:555/stream.sdp'
network_stream = sfac.connect_network_source(
    source_mrl, ColourSpace.BGRA )

The first argument above specifies the Media Resource Locator (MRL) of our network source (the provided link explains the format of this string). If you’re using a device capable of streaming to the network such as an Epiphan Pearl, you can find out its MRL by looking it up in the user’s manual and/or on the admin interface of your device. The second argument specifies that we would like to get the video frames in the BGRA colour space.

For processing video frames obtained from the network_stream object, please see the Processing obtained video frames section. Within all the source code pertaining to that discussion, you can simply replace all occurences of file_reader with the network_stream object we’ve created above. The polymorphism achieved by returning a GIFT-Grab video source from the GIFT-Grab video source factory methods connect_network_source() and create_file_reader() allows video consumers to be agnostic of the actual type of the GIFT-Grab video source object.