Skip to content

Commit

Permalink
Minor feature added + Conda builds
Browse files Browse the repository at this point in the history
- Support for disabling the progress bar
- Added conda builds (for windows only)
  • Loading branch information
MrinalJain17 committed Sep 27, 2018
1 parent 166dac1 commit 15bd658
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 9 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Reading videos into 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.

[Read the Documentation](https://mrinaljain17.github.io/mydia/html/index.html)
[Read the Documentation](https://mrinaljain17.github.io/mydia)

## Getting started

Expand Down Expand Up @@ -38,13 +38,19 @@ The tensor can be interpreted as:

## Installation

- **Install Mydia from PyPI (recommended):**
- **Install from PyPI (Recommended):**

```bash
pip install mydia
```

- **Alternatively, install from Github source:**
- **Install using conda package manager (Supported on Windows only)**

```bash
conda install -c mrinaljain17 mydia
```

- **Alternatively, install from source:**

First, clone the repository

Expand Down
10 changes: 10 additions & 0 deletions conda_build/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Conda Package Manager

Run the following commands from the directory `conda_build/` to build conda distribution
of the package:

```bash
conda-build mydia --numpy 1.14.5 -c mrinaljain17
```

Here, `"mrinaljain17"` is the channel from which `ffmpeg-python` is installed.
2 changes: 2 additions & 0 deletions conda_build/ffmpeg-python/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"%PYTHON%" setup.py install --single-version-externally-managed --record=record.txt
if errorlevel 1 exit 1
1 change: 1 addition & 0 deletions conda_build/ffmpeg-python/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$PYTHON setup.py install --single-version-externally-managed --record=record.txt
34 changes: 34 additions & 0 deletions conda_build/ffmpeg-python/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{% set name = "ffmpeg-python" %}
{% set version = "0.1.16" %}

package:
name: "{{ name|lower }}"
version: "{{ version }}"

source:
url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz
sha256: 721db04120ad110619c17dd7a72db8d21a6738d721be1b3b4c72a7516e6b07f4

build:
number: 0
script: "{{ PYTHON }} -m pip install . --no-deps --ignore-installed -vvv "

requirements:
build:
- future
- pip
- setuptools
- python
- pytest-runner
run:
- future
- python

about:
home: https://github.com/kkroening/ffmpeg-python
license: Apache Software
license_family: APACHE
license_file:
summary: Python bindings for FFmpeg - with complex filtering support
doc_url:
dev_url:
2 changes: 2 additions & 0 deletions conda_build/mydia/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"%PYTHON%" setup.py install --single-version-externally-managed --record=record.txt
if errorlevel 1 exit 1
1 change: 1 addition & 0 deletions conda_build/mydia/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$PYTHON setup.py install --single-version-externally-managed --record=record.txt
39 changes: 39 additions & 0 deletions conda_build/mydia/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{% set name = "mydia" %}
{% set version = "2.1.1" %}

package:
name: "{{ name|lower }}"
version: "{{ version }}"

source:
url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz
sha256: ef07ff6b0c17ddac6749ae6ce9e295a4799dfb14a951bc25ee56778b24684f9a

build:
number: 0
script: "{{ PYTHON }} -m pip install . --no-deps --ignore-installed -vvv "

requirements:
build:
- pip
- setuptools
- python
- ffmpeg-python
- numpy
- matplotlib
- tqdm
run:
- ffmpeg-python
- numpy
- tqdm
- matplotlib
- python

about:
home: https://github.com/MrinalJain17/mydia
license: MIT License
license_family: MIT
license_file:
summary: A simple and efficient wrapper for reading videos as NumPy tensors
doc_url: https://mrinaljain17.github.io/mydia/
dev_url:
10 changes: 8 additions & 2 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
Installation
------------

- **Install Mydia from PyPI (recommended):**
- **Install from PyPI (Recommended):**

.. code:: bash
pip install mydia
- **Alternatively, install from Github source:**
- **Install using conda package manager (Supported on Windows only)**

.. code:: bash
conda install -c mrinaljain17 mydia
- **Alternatively, install from source:**

First, clone the repository.

Expand Down
17 changes: 13 additions & 4 deletions mydia/mydia.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""

__version__ = "2.1.0"
__version__ = "2.1.1"
__author__ = "Mrinal Jain"

import warnings
Expand Down Expand Up @@ -263,11 +263,14 @@ def _probe(self, path):

return (fps, total_frames)

def read(self, paths):
def read(self, paths, verbose=1):
"""Function to read videos
:param paths: A list of paths/path of the video(s) to be read.
:type paths: str or list[str]
:param verbose: If set to 0, the progress bar will be disabled.
:type verbose: int
:return:
A 5-dimensional tensor, whose shape will depend on the value of ``data_format``.
Expand Down Expand Up @@ -298,8 +301,14 @@ def read(self, paths):
paths = [paths]
else:
raise ValueError("Invalid value of 'paths'")

list_of_videos = [self._read_video(path) for path in tqdm(paths, unit="videos")]
disable = False
if verbose == 0:
disable = True

list_of_videos = [
self._read_video(path)
for path in tqdm(paths, unit="videos", disable=disable)
]
video_tensor = np.vstack(list_of_videos)

if self.data_format == "channels_first":
Expand Down

0 comments on commit 15bd658

Please sign in to comment.