Skip to main content

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!

Documentation

Documentation Status

import mediaify

with open('./image.png', 'rb') as f:
    data = f.read()

image = mediaify.encode_image(data, mediaify.WEBPImageFormat(quality=90))
image.save("./image.webp")

Multimedia Support

Supports transcoding of several different media types.

  • Audio
  • Image
  • Animation
  • Video
with open("./audio.mp4", "rb") as f:
    data = f.read()

mediaify.encode_audio(data)
>>> AudioFile(audio/mpeg, 2.5MB)

with open("./image.png", "rb") as f:
    data = f.read()

mediaify.encode_image(data)
>>> ImageFile(1200x1600, image/png, 35.4KB)


with open("./animation.gif", "rb") as f:
    data = f.read()

mediaify.encode_animation(data)
>>> AnimationFile(1280x800, 1.1s 11 frames, 10.0fps, image/gif, 132.8KB)


with open("./examples/input/video.mp4", "rb") as f:
    data = f.read()

mediaify.encode_video(data)
>>> VideoFile(1280x720, 60.458s, 24.0fps, audio, video/mp4, 8.5MB)

Customisable

Encode videos with multiple resolutions, formats, codecs as well as thumbnails and previews easily.

import mediaify

thumbnail = mediaify.ThumbnailEncoding(
    encoding=mediaify.WEBPImageFormat(
        resize=mediaify.TargetResolutionResize(width=640, height=360),
        quality=80,
    ),
)
preview = mediaify.VideoPreviewAnimationEncoding(
    encoding=mediaify.WEBPAnimationFormat(
        resize=mediaify.TargetResolutionResize(width=640, height=360),
        quality=50,
        lossless=False,
    ),
    framerate=5,
    frames=60,
)
video_360p = mediaify.WEBMFormat(
    resize=mediaify.TargetResolutionResize(width=640, height=360),
    video_codec=mediaify.AV1Codec(crf=50, preset=7),
    audio_codec=mediaify.OpusCodec(bitrate=128_000),
)
video_720p = mediaify.WEBMFormat(
    resize=mediaify.TargetResolutionResize(width=1280, height=720),
    video_codec=mediaify.AV1Codec(crf=45, preset=6),
    audio_codec=mediaify.OpusCodec(bitrate=128_000),
)
fallback = mediaify.MP4Format(
    resize=mediaify.TargetResolutionResize(width=1280, height=720),
    video_codec=mediaify.H264Codec(crf=21, preset="medium"),
    audio_codec=mediaify.OpusCodec(bitrate=128_000),
)


configs = [thumbnail, preview, video_360p, video_720p, fallback]
with open('./examples/input/video.mp4', 'rb') as f:
    data = f.read()

mediaify.batch_encode_video(data, configs)
>>> [
    ImageFile(640x360, image/webp, 10.1KB),
    AnimationFile(640x360, 12.0s 60 frames, 5.0fps, image/webp, 1.8MB),
    VideoFile(640x360, 60.45s, 24.0fps, audio, video/webm, 2.2MB),
    VideoFile(1280x720, 60.45s, 24.0fps, audio, video/webm, 4.2MB),
    VideoFile(1280x720, 60.45s, 24.0fps, audio, video/mp4, 14.2MB),
]

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

libmagic

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

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
      • DASH Video
      • Video to Animation
      • Video to Audio
    • Audio Support
  • Better Resizing
    • Blackbars
    • Cropping

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mediaify-3.0.12.tar.gz (43.5 MB view details)

Uploaded Source

Built Distribution

mediaify-3.0.12-py3-none-any.whl (25.7 kB view details)

Uploaded Python 3

File details

Details for the file mediaify-3.0.12.tar.gz.

File metadata

  • Download URL: mediaify-3.0.12.tar.gz
  • Upload date:
  • Size: 43.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for mediaify-3.0.12.tar.gz
Algorithm Hash digest
SHA256 a011169dc6074b5843e9a796b9127594de72aea0e5fd16ca141b3daf17369577
MD5 ad04e79b2aef9fc19c7ac551acfea62d
BLAKE2b-256 b39d100e6b5f6e446509e97073fa446b65d0430cf8163a39f203264060476ab4

See more details on using hashes here.

File details

Details for the file mediaify-3.0.12-py3-none-any.whl.

File metadata

  • Download URL: mediaify-3.0.12-py3-none-any.whl
  • Upload date:
  • Size: 25.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for mediaify-3.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 5a0c395b98e90426cecdd9d222cb9a9702bcb44cf6164404fbf474b038ad3e19
MD5 76ef6e18939d376fe3a22b55bf1e4798
BLAKE2b-256 17d2234dbc846d57020a1ddc505c1bf7ed440c2a959f0bd0f79f2f6de304b02d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page