Metadata-Version: 2.1
Name: mediaify
Version: 2.0.1
Summary: Media encoding made simple
Author-email: Ben Brady <benbradybusiness@gmail.com>
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Multimedia
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Multimedia :: Graphics :: Graphics Conversion
Classifier: Topic :: Multimedia :: Video
Classifier: Topic :: Multimedia :: Video :: Conversion
Classifier: Typing :: Typed
Requires-Dist: python-ffmpeg~=2.0.4
Requires-Dist: MediaInfo~=0.0.9
Requires-Dist: pillow~=9.5.0
Requires-Dist: python_magic~=0.4.27
Requires-Dist: python-magic-bin; sys_platform == 'win32'
Requires-Dist: numexpr
Requires-Dist: libmagic ; extra == "docs"
Requires-Dist: mypy ==0.982 ; extra == "test"
Requires-Dist: pytest >=7.1.3,<8.0.0 ; extra == "test"
Requires-Dist: black == 23.1.0 ; extra == "test"
Project-URL: Documentation, https://mediaify.readthedocs.io/
Project-URL: Source, https://github.com/Ben-Brady/mediaify
Provides-Extra: docs
Provides-Extra: test

# Mediaify

Media encoding made simple!

Encode media without the hassle of wrangling ffmpeg and pillow, instead declare your output declaratively!

[![Documentation Status](https://readthedocs.org/projects/mediaify/badge/?version=latest)](https://mediaify.readthedocs.io/en/latest/?badge=latest)
## [Simple](./examples/simple.py)

```python
import mediaify

with open('ricardo.gif', 'rb') as f:
    data = f.read()

mediaify.batch_encode_animation(data)
>>> [
    ImageFile(51x64, image/webp, 402.0B),
    ImageFile(102x128, image/webp, 808.0B),
    ImageFile(205x256, image/webp, 2.6KB),
    ImageFile(241x300, image/webp, 3.3KB),
    AnimationFile(241x300, 6.4s 128 frames, 20.00fps, image/gif, 400.3KB)
]
```

| 1 | 2 | 3 | 4 | 5 |
| - | - | - | - | - |
| ![](https://raw.githubusercontent.com/Ben-Brady/mediaify/master/examples/output/ricardo-0.webp) | ![](https://raw.githubusercontent.com/Ben-Brady/mediaify/master/examples/output/ricardo-1.webp) | ![](https://raw.githubusercontent.com/Ben-Brady/mediaify/master/examples/output/ricardo-2.webp) | ![](https://raw.githubusercontent.com/Ben-Brady/mediaify/master/examples/output/ricardo-3.webp) | ![](https://raw.githubusercontent.com/Ben-Brady/mediaify/master/examples/output/ricardo-4.gif) |


## [Highly Customisable](./examples/customisable.py)

```python
import mediaify
from mediaify.configs import (
    ResizeConfig,
    WEBPImageEncodeConfig,
    ImageConfig,
    UnencodedConfig,
)

encoding_config = [
    JPEGEncodeConfig(
        resize=ResizeConfig(
            max_height=64,
            max_width=64,
        ),
        quality=80,
    ),
    PNGEncodeConfig(
        resize=ResizeConfig(
            height=256,
            width=256,
        )
    ),
    WEBPImageEncodeConfig(
        quality=90
    ),
    UnencodedConfig()
]


with open('./landscape.webp', 'rb') as f:
    data = f.read()


mediaify.batch_encode_image(data, encoding_config)
>>> [
    ImageFile(64x33, image/webp, 802.0B),
    ImageFile(256x134, image/png, 78.7KB),
    ImageFile(512x268, image/jpeg, 42.3KB),
    ImageFile(1600x840, image/webp, 284.3KB)
]
```

| 1 | 2 | 3 | 4 |
| - | - | - | - |
| ![](https://raw.githubusercontent.com/Ben-Brady/mediaify/master/examples//output/landscape-0.webp) | ![](https://raw.githubusercontent.com/Ben-Brady/mediaify/master/examples//output/landscape-1.png) | ![](https://raw.githubusercontent.com/Ben-Brady/mediaify/master/examples//output/landscape-2.jpg) | ![](https://raw.githubusercontent.com/Ben-Brady/mediaify/master/examples//output/landscape-3.webp) |

## [Multimedia Support](./examples/customisable.py)

```python
import mediaify

with open("./heavy.mp4", "wb") as f:
    mediaify.encode_media(f.read())
>>> VideoFile(1280x720, 13.834s, 24fps, audio, video/mp4, 3.4MB)

with open("./ricardo.gif", "wb") as f:
    mediaify.encode_media(f.read())
>>> AnimationFile(241x300, 6.4s 128 frames, 20.00fps, image/gif, 400.3KB)

with open("./landscape.webp", "wb") as f:
    mediaify.encode_media(f.read())
>>> ImageFile(1600x840, image/webp, 284.3KB)
```

# Installation

[https://pypi.org/project/mediaify/](https://pypi.org/project/mediaify/)

```bash
python -m pip install mediaify
```

## Dependencies

### ffmpeg

Ensure ffmpeg is installed and on $PATH, try running `ffmpeg` to check

- Debain/Ubuntu: `sudo apt-get install ffmpeg`
- Other: [https://ffmpeg.org/download.html](https://ffmpeg.org/download.html)

### libmagic

- Windows: N/A, installed automatically
- Debian/Ubuntu: `sudo apt-get install libmagic1`
- Homebrew: `brew install libmagic`
- macports: `port install file`

# Documentation

[https://mediaify.readthedocs.io/](https://mediaify.readthedocs.io/)

# Roadmap

If you want any of these features to be developed, just flag an issue and I'll work on it.

- New Encoders
    - [x] Video
        - [X] WEBM
        - [X] MP4
        - [ ] Video to Animation
    - [x] Audio Support
- Better Resizing
    - [ ] Min Size
    - [ ] Cropping
    - [ ] Blackbars

