Media encoding made simple
Project description
Mediaify
Media encoding made simple!
Encode media without the hassle of wrangling ffmpeg and pillow, instead declare your output declaratively!
Simple
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 |
---|---|---|---|---|
Highly Customisable
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 |
---|---|---|---|
Multimedia Support
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/
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
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/
Roadmap
If you want any of these features to be developed, just flag an issue and I'll work on it.
- New Encoders
- Video
- WEBM
- MP4
- Video to Animation
- Audio Support
- Video
- Better Resizing
- Min Size
- Cropping
- Blackbars
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mediaify-2.0.1.tar.gz
(12.8 kB
view hashes)
Built Distribution
mediaify-2.0.1-py3-none-any.whl
(19.3 kB
view hashes)