Reading videos as NumPy arrays was never more simple. This library provides an entire range of additional functionalities such as custom frame selection, frame resizing, pixel normalization, grayscale conversion and much more.
# Import
from mydia import Videos
# Initialize video path
video_path = r".docs/examples/sample_video/bigbuckbunny.mp4"
# Create a reader object
reader = Videos()
# Call the 'read()' function to get the video tensor
# which will be of shape (1, 132, 720, 1280, 3)
video = reader.read(video_path)
The tensor can be interpreted as:
- 1 video
- Having 132 frames,
- Dimension (width x height) of each frame: 1280x720 pixels
3
denotes that the video is in RGB format
from mydia import Videos
video_paths = [
"path/to/video_1",
"path/to/video_2",
"path/to/video_3",
...,
]
reader = Videos()
video = reader.read(video_path, workers=4)
3. View detailed examples here
-
Python 3.x
(preferably from the Anaconda Distribution) -
FFmpeg
: The backend for reading and processing the videos.The recommended (and probably the easiest) way of installing
FFmpeg
is via the conda package manager.conda install -c mrinaljain17 ffmpeg
However, if you are not using conda, then
For Linux users -
$ sudo apt-get update $ sudo apt-get install ffmpeg
For Windows or OSX users -
Download the required binaries from here. Extract the zip file and add the location of binaries to the
PATH
variable.
-
Using the conda package manager (recommended):
conda install -c mrinaljain17 mydia
-
Using pip:
pip install mydia
The following python packages that mydia
depends on, will also be
installed, along with their dependencies.
- ffmpeg-python
- Numpy
- tqdm - Required for displaying the progress bar.
Copyright 2018 Mrinal Jain.
Released under the MIT License.