Reading video files

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 read a video file, we first obtain the GIFT-Grab video source factory singleton:

from pygiftgrab import VideoSourceFactory
sfac = VideoSourceFactory.get_instance()

Then we create a file reader using the obtained factory:

from pygiftgrab import ColourSpace
file_reader = sfac.create_file_reader(
    '/tmp/myinput.mp4', ColourSpace.I420 )

The second argument above specifies that we would like to get the video frames in the I420 colour space. The file_reader object automatically starts reading the frames in /tmp/myinput.mp4 one by one, at the file’s frame rate.

Processing obtained video frames

To process the frames, we need to attach an observer to our file_reader, which is already an observable object. You can see how to do this in one of the following examples: