components.io.videofilereader2
- class VideoFileReader2(config={}, **kwds)[source]
Bases:
ComponentRead raw or conventional (mp4, flv, AVI, etc.) video files.
This component uses FFmpeg to read video from a wide variety of formats, including “raw” files without a header. Make sure you have installed FFmpeg before attempting to use
VideoFileReader2.Unlike
VideoFileReaderthe file data is not always converted to Y or RGB video format. This may be useful if you want to process the YUV data directly, rather than having to convert it from RGB to YUV again.The
formatconfig item can be used to force conversion to a particular format. This can be useful if most of your sources are in the same format but you’d like your script to work with sources in any format.The
zperiodconfig item can be used to adjust the repeat period so it is an integer multiple of a chosen number, e.g. 4 frames for a PAL encoded sequence. It has no effect ifloopingisoff.“Raw” video files
Video is usually stored in file formats (such as AVI) with a complex structure to allow a mix of audio, video and other data. “Raw” files contain nothing but the picture data. Even the image dimensions have to be stored in a separate “metadata” file. (Use the
pyctools-setmetadatatool to create or modify the metadata file.)There are many possible arrangements of data in raw files. For example, the colour components can be packed (multiplexed) together or stored in separate planes. The formats are labelled with a short string known as a fourcc code. This code needs to be in the metadata file with the image dimensions.
Note that when reading “YUV” formats the U & V outputs are offset by 128 to restore their range to -128..127 (from the file range of 0..255). This makes subsequent processing a lot easier.
Config
pathstr
Path name of file to be read.
formatstr
Force output format. Can be
'native','RGB','Y','YUV444','YUV422', or'YUV420'.loopingstr
Whether to play continuously. Can be
'off'or'repeat'.noauditbool
Don’t output file’s “audit trail” metadata.
zperiodint
Adjust repeat period to an integer multiple of
zperiod.- outputs = ['output_Y_RGB', 'output_UV']
Comments or questions? Please email jim@jim-easterbrook.me.uk.