abhiTronix / benchmarking_video_reading_python

Comparing speed of different implementations of reading video into numpy arrays

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Benchmarking Video Reading

Tested using Python 3.7.0 on Ubuntu 20.04 LTS with Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (4-core, 8-thread CPU)

Hard disk: Sequential Read - 560 MB/s CT2000MX500SSD1 Crucial MX500 2TB 3D NAND SATA 2.5 inch 7mm (with 9.5mm adapter) Internal SSD

The baseline benchmark is a simple cv2.VideoCapture() reader with .read() method in serial.

In these benchmarks I compare the speed of sequentially reading a file; if one wishes to sample frames across a file, Decord maybe a good option, especially if its part of a machine learning pipeline as it has automatic conversion to PyTorch/Tensorflow arrays.

Note: In the below I am varying whether the CONSUMER of frames is blocked via IO or CPU limitations, whereby the consumer is calling a producer video reader library which reads a video file as fast as my hard disk allows (i.e. I am not applying a blocking call inside the reader, which might emulate e.g. reading a huge video file, but instead emulating the more common use case of an application that gets blocked during processing of that video file).

Low Resolution input video (480x270 pixels)

Unblocked

IO Limited

CPU Limited

Medium Resolution input video (720x480 pixels)

Unblocked

IO Limited

CPU Limited

High Resolution input video (1920x1080 pixels)

Unblocked

IO Limited

CPU Limited

How To Run

git lfs install

git lfs pull # to get video

pip install -r requirements.txt

pip install -e setup.py

Output

Timings can be found in the ./timings folder.

Timings are reported over 1000 frames as time_for_all_frames (seconds) +/- stddev_for_all_frames (seconds) with this standard deviation calculatied over 3 repeats. time_per_frame is calculated as time_for_all_frames/1000 and the FPS is calculated as 1/time_per_frame.

About

Comparing speed of different implementations of reading video into numpy arrays

License:MIT License


Languages

Language:Jupyter Notebook 81.0%Language:Python 18.7%Language:Shell 0.3%