MPGIF is a modern, lightweight animation format designed to bridge the gap between heavy video files and inefficient GIFs. It combines WebP image compression with Opus/MP3 audio encoding to deliver high-quality, sound-enabled animations at a fraction of the size.
- Optimized Compression: Uses WebP for frames and MP3 for audio, offering superior quality-to-size ratio compared to GIF.
- Audio Support: Unlike standard GIFs, MPGIF supports synchronized audio tracks.
- Portable Player: Includes a standalone, lightweight player that requires no installation.
- Web Ready: Comes with a JavaScript decoder (
mpgif_reader.js) for seamless integration into websites. - Zero-Dependency Mode: Can automatically download necessary engines (FFmpeg) if missing, or run in a fully portable "frozen" mode.
- Python 3.10+ (for source execution)
- FFmpeg (optional, auto-downloaded if missing)
git clone https://github.com/Gautier-Jourdon/MPGIF.git
cd MPGIF
pip install -r requirements.txt(Note: requirements.txt should include opencv-python, numpy, pygame, pillow, imageio, imageio-ffmpeg)
You can run the application via the command line or use the built-in GUI.
Simply double-click MPGIF Reader.exe (if built) or run:
python main.pyThis launches a user-friendly hub to Play, Convert, or Decode files.
1. Encode a Video to MPGIF
python main.py encode "input.mp4" "output.mpgif" --fps 15 --width 480 --quality 752. Play an MPGIF
python main.py play "animation.mpgif"3. Decode MPGIF back to MP4
python main.py decode "animation.mpgif" "output.mp4"To create a standalone .exe for Windows distribution:
- Generate Icons:
python deployment/create_icons.py
- Build Executable:
python deployment/build.py
The resulting MPGIF Reader.exe will be found in the dist/ folder.
To embed an MPGIF on your website:
<canvas id="myCanvas"></canvas>
<script src="web/mpgif_reader.js"></script>
<script>
const player = new MPGIFReader('animation.mpgif');
player.load().then(() => {
player.play(document.getElementById('myCanvas'));
});
</script>MPGIF files follow a custom binary structure:
- Header: Magic string
MPGIF+ Version. - Metadata: JSON block containing FPS, frame count, width, height, and audio codec info.
- Audio Block: Compressed audio data size + payload.
- Frame Index: Offset table for quick seeking.
- Frame Data: Sequential WebP chunks.
This project is open-source and available under the Apache 2.0 License.