|
| 1 | +Mydia |
| 2 | +===== |
| 3 | + |
| 4 | +Read videos as numpy arrays, with a gamut of additional functionalities. |
| 5 | + |
| 6 | +`Read the Documentation <https://mrinaljain17.github.io/mydia/>`__ |
| 7 | + |
| 8 | +Getting started |
| 9 | +--------------- |
| 10 | + |
| 11 | +*Let's read in a video* |
| 12 | + |
| 13 | +.. code:: python |
| 14 | +
|
| 15 | + from mydia import Videos |
| 16 | +
|
| 17 | + video_path = r'./static/sample_video/bigbuckbunny.mp4' |
| 18 | + reader = Videos() |
| 19 | +
|
| 20 | + video = reader.read(video_path) # a tensor of shape (1, 132, 720, 1080, 3) |
| 21 | +
|
| 22 | +The tensor represents **1 video** having **132 frames**, with each frame |
| 23 | +having a width and height of 1080 and 720 pixels respectively. ``3`` |
| 24 | +denotes the *RGB channels* of the video. |
| 25 | + |
| 26 | +*Extracting only 9 frames (at equal intervals) from the entire video and |
| 27 | +resizing each frame to be 720 pixels in width and 480 pixels in height.* |
| 28 | + |
| 29 | +.. code:: python |
| 30 | +
|
| 31 | + from mydia import Videos |
| 32 | +
|
| 33 | + video_path = r'./static/sample_video/bigbuckbunny.mp4' |
| 34 | + reader = Videos(target_size=(720, 480), |
| 35 | + num_frames=9) |
| 36 | +
|
| 37 | + video = reader.read(video_path) # a tensor of shape (1, 9, 480, 720, 3) |
| 38 | +
|
| 39 | + reader.plot(video[0]) # Plotting the frames of the video in a grid |
| 40 | +
|
| 41 | +.. figure:: https://github.com/MrinalJain17/mydia/raw/master/static/images/video_frames.PNG |
| 42 | + :alt: Video frames |
| 43 | + |
| 44 | + |
| 45 | +Hmm.. Let's read the same video in **gray scale** |
| 46 | + |
| 47 | +.. code:: python |
| 48 | +
|
| 49 | + from mydia import Videos |
| 50 | +
|
| 51 | + video_path = r'./static/sample_video/bigbuckbunny.mp4' |
| 52 | + reader = Videos(target_size=(720, 480), |
| 53 | + to_gray=True, |
| 54 | + num_frames=9) |
| 55 | +
|
| 56 | + video = reader.read(video_path) # a tensor of shape (1, 9, 480, 720, 1) |
| 57 | +
|
| 58 | + reader.plot(video[0]) # Plotting the frames of the video in a grid |
| 59 | +
|
| 60 | +.. figure:: https://github.com/MrinalJain17/mydia/raw/master/static/images/video_frames_gray.PNG |
| 61 | + :alt: Video frames |
| 62 | + |
| 63 | +Installation |
| 64 | +------------ |
| 65 | + |
| 66 | +- **Install Mydia from PyPI (recommended):** |
| 67 | + |
| 68 | +.. code:: bash |
| 69 | +
|
| 70 | + pip install mydia |
| 71 | +
|
| 72 | +- **Alternatively, install from Github source:** |
| 73 | + |
| 74 | +First, clone the repository. |
| 75 | + |
| 76 | +.. code:: bash |
| 77 | +
|
| 78 | + git clone https://github.com/MrinalJain17/mydia.git |
| 79 | +
|
| 80 | +Then, build the module |
| 81 | + |
| 82 | +.. code:: bash |
| 83 | +
|
| 84 | + cd mydia |
| 85 | + python setup.py install |
| 86 | +
|
| 87 | +Requirements |
| 88 | +------------ |
| 89 | + |
| 90 | +``Python 3.x`` (preferably from the `Anaconda Distribution <https://www.anaconda.com/download/>`__) |
| 91 | + |
| 92 | +The program uses `Scikit-video <http://www.scikit-video.org/stable/>`__, which requires ``FFmpeg`` to be installed on the system. |
| 93 | +To install ``FFmpeg`` on your machine |
| 94 | + |
| 95 | +For **Linux**: |
| 96 | + |
| 97 | +:: |
| 98 | + |
| 99 | + $ sudo apt-get update |
| 100 | + $ sudo apt-get install libav-tools |
| 101 | + |
| 102 | +For **Windows or MAC/OSX**: |
| 103 | +Download the required binaries from `here <https://www.ffmpeg.org/download.html>`__. Extract the zip file and add the location of binaries to the ``PATH`` variable |
| 104 | + |
| 105 | +Additional Libraries to install: |
| 106 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 107 | + |
| 108 | +Several libraries like `Numpy <http://www.numpy.org/>`__, `Pillow <https://python-imaging.github.io/>`__, `Matplotlib <https://matplotlib.org/>`__ etc., required for the package come pre-installed with the Anaconda distribution of Python. |
| 109 | + |
| 110 | +Install the following extra packages (if not already installed): |
| 111 | + |
| 112 | +`Scikit-video <http://www.scikit-video.org/stable/>`__ |
| 113 | + :: |
| 114 | + |
| 115 | + pip install sk-video |
| 116 | + |
| 117 | +`tqdm <https://pypi.python.org/pypi/tqdm#installation>`__ - Required for displaying the progress bar. |
| 118 | + :: |
| 119 | + |
| 120 | + pip install tqdm |
0 commit comments