Skip to content

Commit 7530078

Browse files
authored
Alternate backend (#14)
* Major changes in API - `Scikit-video` is no longer being used as the backend. The new backend is now [ffmpeg-python](https://github.com/kkroening/ffmpeg-python) - Related dependencies have been removed (Pillow) - Removed `required_fps` parameter, and in order to simplify the API, merged the functionality of `mode` and `extract_position` - Added type annotations - Initial support for custom frame selection - Refactored code - Version bump to 2.0.0b * Subsequent changes in docs and related functions - Added `plot()` - Updated documentation - Bumped version to 2.0.0 * Minor API change and docs update - `TargetSize` moved from utils.py to mydia.py, which makes much more sense as cannot be categorized as a utility. - Docs update - Updated README.rst to reflect the updates in the API * Minor type fix in README.rst
1 parent 2a5d91d commit 7530078

10 files changed

+333
-311
lines changed

README.rst

+23-15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
21
Mydia
32
=====
43

5-
Reading videos into NumPy arrays was never more simple. In addition,
6-
this library also provides an entire range of additional functionalities
7-
for reading the videos.
4+
Reading videos into NumPy arrays was never more simple. This library provides
5+
an entire range of additional functionalities such as custom frame selection,
6+
frame resizing, pixel normalization, grayscale conversion and much more.
87

98
`Read the Documentation <https://mrinaljain17.github.io/mydia/>`__
109

@@ -64,8 +63,11 @@ Requirements
6463
``Python 3.x`` (preferably from the `Anaconda
6564
Distribution <https://www.anaconda.com/download/>`__)
6665

67-
The program uses `Scikit-video <http://www.scikit-video.org/stable/>`__, which requires
68-
``FFmpeg`` to be installed on the system. To install ``FFmpeg`` on your machine -
66+
The program uses `ffmpeg-python <https://github.com/kkroening/ffmpeg-python>`__, which provides
67+
python bindings for `FFmpeg <https://www.ffmpeg.org/>`__ (used as the backend for reading and
68+
processing videos)
69+
70+
To install ``FFmpeg`` on your machine -
6971

7072
For **Linux** users:
7173

@@ -83,24 +85,30 @@ For **Windows or MAC/OSX** users:
8385
Additional Libraries to install:
8486
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8587

86-
Several libraries like `Numpy <http://www.numpy.org/>`__,
87-
`Pillow <https://python-imaging.github.io/>`__ and
88-
`Matplotlib <https://matplotlib.org/>`__, required for the package come
89-
pre-installed with the Anaconda distribution for Python. If you are not
90-
using the default anaconda distribution, then first install the packages
91-
mentioned above and along with their dependencies.
88+
Install the following packages along with their dependencies:
89+
90+
- `ffmpeg-python <https://github.com/kkroening/ffmpeg-python>`__
91+
92+
.. code:: bash
9293
93-
Also, install the following additional packages:
94+
pip install ffmpeg-python
9495
95-
- `Scikit-video <http://www.scikit-video.org/stable/>`__
96+
- `Numpy <http://www.numpy.org/>`__
9697

9798
.. code:: bash
9899
99-
pip install sk-video
100+
pip install numpy
100101
101102
- `tqdm <https://pypi.python.org/pypi/tqdm#installation>`__ - Required
102103
for displaying the progress bar.
103104

104105
.. code:: bash
105106
106107
pip install tqdm
108+
109+
- `Matplotlib <https://matplotlib.org/>`__ - (Optional) For plotting the frames
110+
of a video
111+
112+
.. code:: bash
113+
114+
pip install matplotlib

docs/examples/plot_1_getting_started.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
Get started with some basics
33
============================
44
5-
Reading videos into NumPy arrays was never more simple. In addition,
6-
this library also provides an entire range of additional functionalities
7-
for reading the videos.
5+
Reading videos into NumPy arrays was never more simple. This library provides
6+
an entire range of additional functionalities such as custom frame selection,
7+
frame resizing, pixel normalization, grayscale conversion and much more.
8+
89
"""
910

1011
##############################################################################

docs/examples/plot_2_frame_selection.py

+30-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
2-
Frame selection and resizing
3-
============================
2+
Frame selection, resizing, and grayscale conversion
3+
===================================================
44
55
- We want to resize each frame to be 720 pixels in width and 480 pixels
66
in height.
@@ -11,7 +11,7 @@
1111

1212
# Imports
1313
import matplotlib.pyplot as plt
14-
from mydia import Videos
14+
from mydia import Videos, plot
1515

1616
# Initialize video path
1717
video_path = r"./sample_video/bigbuckbunny.mp4"
@@ -26,9 +26,35 @@
2626
video = reader.read(video_path) # a tensor of shape (1, 12, 480, 720, 3)
2727

2828
# Plot the video frames in a grid
29-
reader.plot(video[0])
29+
plot(video[0])
3030
plt.show()
3131

3232
##############################################################################
3333
# .. note:: The number of channels for a RGB video is 3
3434
# (indicated by the last value in the tuple).
35+
#
36+
#
37+
# - Now let's read the video with the same parameters, but in grayscale
38+
39+
# Imports
40+
import matplotlib.pyplot as plt
41+
from mydia import Videos, plot
42+
43+
# Initialize video path
44+
video_path = r"./sample_video/bigbuckbunny.mp4"
45+
46+
# Configuring the parameters
47+
# Other parameters are the same as described above.
48+
# The only additional parameter to modify is 'to_gray'
49+
reader = Videos(target_size=(720, 480), to_gray=True, num_frames=12)
50+
51+
# Call the 'read()' function to get the required video tensor
52+
video = reader.read(video_path) # a tensor of shape (1, 12, 480, 720, 1)
53+
54+
# Plot the video frames in a grid
55+
plot(video[0])
56+
plt.show()
57+
58+
##############################################################################
59+
# .. note:: The number of channels for a video in gray scale is 1
60+
# (indicated by the last value in the tuple).

docs/examples/plot_3_frame_selection_with_gray.py

-34
This file was deleted.

docs/source/conf.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,18 @@
1919
import sphinx_rtd_theme
2020
from sphinx_gallery.sorting import FileNameSortKey
2121

22+
from mydia import mydia
23+
2224
# -- Project information -----------------------------------------------------
2325

2426
project = "Mydia"
2527
copyright = "2018, Mrinal Jain"
2628
author = "Mrinal Jain"
2729

2830
# The short X.Y version
29-
version = "1.0"
31+
version = "2.0"
3032
# The full version, including alpha/beta/rc tags
31-
release = "1.0.5"
33+
release = mydia.__version__
3234

3335

3436
# -- General configuration ---------------------------------------------------

docs/source/install.rst

+20-11
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ Requirements
2828
``Python 3.x`` (preferably from the `Anaconda
2929
Distribution <https://www.anaconda.com/download/>`__)
3030

31-
The program uses `Scikit-video <http://www.scikit-video.org/stable/>`__, which requires
32-
``FFmpeg`` to be installed on the system. To install ``FFmpeg`` on your machine -
31+
The program uses `ffmpeg-python <https://github.com/kkroening/ffmpeg-python>`__, which provides
32+
python bindings for `FFmpeg <https://www.ffmpeg.org/>`__ (used as the backend for reading and
33+
processing videos)
34+
35+
To install ``FFmpeg`` on your machine -
3336

3437
For **Linux** users:
3538

@@ -47,24 +50,30 @@ For **Windows or MAC/OSX** users:
4750
Additional Libraries to install:
4851
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4952

50-
Several libraries like `Numpy <http://www.numpy.org/>`__,
51-
`Pillow <https://python-imaging.github.io/>`__ and
52-
`Matplotlib <https://matplotlib.org/>`__, required for the package come
53-
pre-installed with the Anaconda distribution for Python. If you are not
54-
using the default anaconda distribution, then first install the packages
55-
mentioned above and along with their dependencies.
53+
Install the following packages along with their dependencies:
54+
55+
- `ffmpeg-python <https://github.com/kkroening/ffmpeg-python>`__
56+
57+
.. code:: bash
5658
57-
Also, install the following additional packages:
59+
pip install ffmpeg-python
5860
59-
- `Scikit-video <http://www.scikit-video.org/stable/>`__
61+
- `Numpy <http://www.numpy.org/>`__
6062

6163
.. code:: bash
6264
63-
pip install sk-video
65+
pip install numpy
6466
6567
- `tqdm <https://pypi.python.org/pypi/tqdm#installation>`__ - Required
6668
for displaying the progress bar.
6769

6870
.. code:: bash
6971
7072
pip install tqdm
73+
74+
- `Matplotlib <https://matplotlib.org/>`__ - (Optional) For plotting the frames
75+
of a video
76+
77+
.. code:: bash
78+
79+
pip install matplotlib

mydia/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
from .mydia import Videos
1+
from .mydia import *
2+
from .utils import _mode_auto, _mode_first, _mode_last, _mode_middle, _mode_random

0 commit comments

Comments
 (0)