From 15bd65893076b051484cbc76f68cc8c9ca1eb9c9 Mon Sep 17 00:00:00 2001 From: Mrinal Jain Date: Fri, 28 Sep 2018 00:36:59 +0530 Subject: [PATCH] Minor feature added + Conda builds - Support for disabling the progress bar - Added conda builds (for windows only) --- README.md | 12 ++++++--- conda_build/README.md | 10 ++++++++ conda_build/ffmpeg-python/bld.bat | 2 ++ conda_build/ffmpeg-python/build.sh | 1 + conda_build/ffmpeg-python/meta.yaml | 34 +++++++++++++++++++++++++ conda_build/mydia/bld.bat | 2 ++ conda_build/mydia/build.sh | 1 + conda_build/mydia/meta.yaml | 39 +++++++++++++++++++++++++++++ docs/source/install.rst | 10 ++++++-- mydia/mydia.py | 17 ++++++++++--- 10 files changed, 119 insertions(+), 9 deletions(-) create mode 100644 conda_build/README.md create mode 100644 conda_build/ffmpeg-python/bld.bat create mode 100644 conda_build/ffmpeg-python/build.sh create mode 100644 conda_build/ffmpeg-python/meta.yaml create mode 100644 conda_build/mydia/bld.bat create mode 100644 conda_build/mydia/build.sh create mode 100644 conda_build/mydia/meta.yaml diff --git a/README.md b/README.md index 765c616..8b3792e 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/conda_build/README.md b/conda_build/README.md new file mode 100644 index 0000000..71a0d16 --- /dev/null +++ b/conda_build/README.md @@ -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. diff --git a/conda_build/ffmpeg-python/bld.bat b/conda_build/ffmpeg-python/bld.bat new file mode 100644 index 0000000..b9cd616 --- /dev/null +++ b/conda_build/ffmpeg-python/bld.bat @@ -0,0 +1,2 @@ +"%PYTHON%" setup.py install --single-version-externally-managed --record=record.txt +if errorlevel 1 exit 1 diff --git a/conda_build/ffmpeg-python/build.sh b/conda_build/ffmpeg-python/build.sh new file mode 100644 index 0000000..a660906 --- /dev/null +++ b/conda_build/ffmpeg-python/build.sh @@ -0,0 +1 @@ +$PYTHON setup.py install --single-version-externally-managed --record=record.txt diff --git a/conda_build/ffmpeg-python/meta.yaml b/conda_build/ffmpeg-python/meta.yaml new file mode 100644 index 0000000..3c83df4 --- /dev/null +++ b/conda_build/ffmpeg-python/meta.yaml @@ -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: diff --git a/conda_build/mydia/bld.bat b/conda_build/mydia/bld.bat new file mode 100644 index 0000000..b9cd616 --- /dev/null +++ b/conda_build/mydia/bld.bat @@ -0,0 +1,2 @@ +"%PYTHON%" setup.py install --single-version-externally-managed --record=record.txt +if errorlevel 1 exit 1 diff --git a/conda_build/mydia/build.sh b/conda_build/mydia/build.sh new file mode 100644 index 0000000..a660906 --- /dev/null +++ b/conda_build/mydia/build.sh @@ -0,0 +1 @@ +$PYTHON setup.py install --single-version-externally-managed --record=record.txt diff --git a/conda_build/mydia/meta.yaml b/conda_build/mydia/meta.yaml new file mode 100644 index 0000000..ca63441 --- /dev/null +++ b/conda_build/mydia/meta.yaml @@ -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: diff --git a/docs/source/install.rst b/docs/source/install.rst index 1719547..b6b3843 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -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. diff --git a/mydia/mydia.py b/mydia/mydia.py index de8da11..b7f274b 100644 --- a/mydia/mydia.py +++ b/mydia/mydia.py @@ -7,7 +7,7 @@ """ -__version__ = "2.1.0" +__version__ = "2.1.1" __author__ = "Mrinal Jain" import warnings @@ -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``. @@ -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":