API Reference >> skvideo.io.LibAVReader
Fork me on GitHub

skvideo.io.LibAVReader

class skvideo.io.LibAVReader(*args, **kwargs)[source]

Reads frames using Libav Using libav as a backend, this class provides sane initializations meant to handle the default case well.

Methods

getShape()

Returns a tuple (T, M, N, C)

nextFrame()

Yields frames using a generator

close

__init__(*args, **kwargs)[source]

Initializes FFmpeg in reading mode with the given parameters

During initialization, additional parameters about the video file are parsed using skvideo.io.ffprobe. Then FFmpeg is launched as a subprocess. Parameters passed into inputdict are parsed and used to set as internal variables about the video. If the parameter, such as “Height” is not found in the inputdict, it is found through scanning the file’s header information. If not in the header, ffprobe is used to decode the file to determine the information. In the case that the information is not supplied and connot be inferred from the input file, a ValueError exception is thrown.

Parameters:
filenamestring

Video file path

inputdictdict

Input dictionary parameters, i.e. how to interpret the input file.

outputdictdict

Output dictionary parameters, i.e. how to encode the data when sending back to the python process.

start_frameint

Skip the first start_frame frames of the input (issue #166). Uses FFmpeg’s fast keyframe-based -ss seek (input seeking), so the actual first frame returned may snap to the nearest keyframe at or before the requested position. Combine with num_frames for a windowed read. For frame-exact extraction, pass outputdict={"-vf": "select='gte(n\\,N)'", "-vsync": "0"} instead (-vf is an output filter, so it must go in outputdict; -vsync 0 stops FFmpeg from re-padding the dropped frames back to a constant rate, and on FFmpeg 5.1+ is equivalent to -fps_mode passthrough). That is slower because it decodes from the start of the file.

Returns:
none
getShape()

Returns a tuple (T, M, N, C)

Returns the video shape in number of frames, height, width, and channels per pixel.

nextFrame()

Yields frames using a generator

Returns T ndarrays of size (M, N, C), where T is number of frames, M is height, N is width, and C is number of channels per pixel.