Skip to main content

Read videos as numpy arrays

Project description

Read videos as numpy arrays, with a gamut of additional functionalities.

Read the Documentation

Getting started

Let’s read in a video

from mydia import Videos

video_path = r'./static/sample_video/bigbuckbunny.mp4'
reader = Videos()

video = reader.read(video_path)   # a tensor of shape (1, 132, 720, 1080, 3)

The tensor represents 1 video having 132 frames, with each frame having a width and height of 1080 and 720 pixels respectively. 3 denotes the RGB channels of the video.

Extracting only 9 frames (at equal intervals) from the entire video and resizing each frame to be 720 pixels in width and 480 pixels in height.

from mydia import Videos

video_path = r'./static/sample_video/bigbuckbunny.mp4'
reader = Videos(target_size=(720, 480),
                num_frames=9)

video = reader.read(video_path)   # a tensor of shape (1, 9, 480, 720, 3)

reader.plot(video[0])   # Plotting the frames of the video in a grid
Video frames

Hmm.. Let’s read the same video in gray scale

from mydia import Videos

video_path = r'./static/sample_video/bigbuckbunny.mp4'
reader = Videos(target_size=(720, 480),
                to_gray=True,
                num_frames=9)

video = reader.read(video_path)   # a tensor of shape (1, 9, 480, 720, 1)

reader.plot(video[0])   # Plotting the frames of the video in a grid
Video frames

Installation

  • Install Mydia from PyPI (recommended):

pip install mydia
  • Alternatively, install from Github source:

First, clone the repository and then build the module.

git clone https://github.com/MrinalJain17/mydia.git
cd mydia
python setup.py install

Requirements

Python 3.x (preferably from the Anaconda Distribution)

The program uses Scikit-video, which requires FFmpeg to be installed on the system. To install FFmpeg on your machine

For Linux:

$ sudo apt-get update
$ sudo apt-get install libav-tools

For Windows or MAC/OSX: Download the required binaries from here. Extract the zip file and add the location of binaries to the PATH variable

Additional Libraries to install:

Several libraries like Numpy, Pillow, Matplotlib etc., required for the package come pre-installed with the Anaconda distribution of Python.

Install the following extra packages (if not already installed):

Scikit-video

pip install sk-video

tqdm - Required for displaying the progress bar.

pip install tqdm

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mydia-1.0.3.tar.gz (6.8 kB view hashes)

Uploaded Source

Built Distribution

mydia-1.0.3-py3-none-any.whl (6.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page