livephoto-to-gif
Live Photo to GIF — free browser tool for converting Live Photo videos into animated GIFs (the reference UI for this library).
Offline Python library for converting Live Photo videos (MOV/MP4) and .livp containers into optimized animated GIFs using FFmpeg.
Package: livephoto-to-gif on PyPI (0.1.0).
System Requirements
FFmpeg must be installed on your system and available in your PATH.
- macOS:
brew install ffmpeg - Ubuntu/Debian:
sudo apt install ffmpeg - Windows: Download from ffmpeg.org
The library raises FFmpegNotFoundError if FFmpeg is missing. Conversion failures raise ConversionError with FFmpeg stderr details.
Install
pip install livephoto-to-gif
Quick start
from livephoto_to_gif import convert_to_gif
# Convert a Live Photo video to GIF
convert_to_gif("live_photo.mov", "output.gif")
# Or let it auto-generate the output filename
convert_to_gif("live_photo.mov") # creates live_photo.gif
CLI
livephoto-to-gif live_photo.mov -o output.gif
livephoto-to-gif video.mp4 --fps 15 --width 480
livephoto-to-gif photo.livp -o photo.gif
API
Class API
| Method | Description |
|---|---|
LivePhotoToGifConverter(fps=15, width=480, loop=0) |
Initialize converter with output settings |
.convert(input_path, output_path=None) |
Convert video/.livp to GIF file (returns Path) |
.convert_to_bytes(input_path) |
Convert and return GIF bytes |
Parameters:
fps: Output frame rate (default: 15)width: Max output width in pixels; height scales proportionally (default: 480)loop: Number of times to loop (0 = infinite, default: 0)dither: FFmpeg dithering algorithm (default:"bayer")scale_filter: FFmpeg scaling filter (default:"lanczos")
Convenience functions
| Function | Role |
|---|---|
convert_to_gif(input_path, output_path=None, fps=15, width=480, loop=0) |
One-shot conversion |
is_live_photo_video(file_path) |
Check supported extension (.mov, .mp4, .m4v, .livp) |
extract_video_from_livp(livp_path, dest_dir) |
Extract embedded video from a .livp ZIP container |
Exceptions
| Exception | When |
|---|---|
FFmpegNotFoundError |
ffmpeg binary not found in PATH |
ConversionError |
FFmpeg ran but conversion failed |
Examples
Basic conversion
from livephoto_to_gif import convert_to_gif
convert_to_gif("live_photo.mov", "animation.gif")
output = convert_to_gif("video.mp4")
print(f"Created: {output}") # Created: video.gif
Custom output settings
from livephoto_to_gif import LivePhotoToGifConverter
converter = LivePhotoToGifConverter(
fps=20,
width=640,
loop=5,
)
converter.convert("video1.mov", "output1.gif")
converter.convert("video2.mp4", "output2.gif")
.livp containers
Some Live Photo exports (especially Android) ship as a .livp ZIP archive containing a still image plus a short video. The library extracts the embedded .mov/.mp4/.m4v and converts it:
from livephoto_to_gif import convert_to_gif
convert_to_gif("photo.livp", "photo.gif")
Work with bytes in memory
from livephoto_to_gif import LivePhotoToGifConverter
converter = LivePhotoToGifConverter()
gif_bytes = converter.convert_to_bytes("live_photo.mov")
with open("output.gif", "wb") as f:
f.write(gif_bytes)
Error handling
from livephoto_to_gif import convert_to_gif, ConversionError, FFmpegNotFoundError
try:
convert_to_gif("live_photo.mov", "output.gif")
except FFmpegNotFoundError:
print("Please install FFmpeg: https://ffmpeg.org/download.html")
except FileNotFoundError:
print("Input file not found")
except ValueError as e:
print(f"Invalid input: {e}")
except ConversionError as e:
print(f"Conversion failed: {e}")
How it works
This library uses FFmpeg with a two-pass palette optimization:
- Palette generation: FFmpeg analyzes the video and generates an optimized 256-color palette using
palettegenwith diff stats mode - GIF encoding: The video is re-encoded using
paletteusewith the generated palette and Bayer dithering
FFmpeg command equivalent:
ffmpeg -i input.mov \
-vf "fps=15,scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen=stats_mode=diff[p];[s1][p]paletteuse=dither=bayer" \
-loop 0 \
output.gif
Supported formats
| Format | Extension | Notes |
|---|---|---|
| QuickTime | .mov |
Typical Live Photo video export from iPhone |
| MP4 | .mp4, .m4v |
Alternative video containers |
| Live Photo package | .livp |
ZIP archive with an embedded video clip |
Export the video component of an Apple Live Photo (Share → Save to Files), not the still HEIC. Apple still+video pairs are not a single .livp file; use the exported .mov/.mp4.
Tests
pip install -e ".[test]"
pytest
pytest --cov=livephoto_to_gif
Tests use committed fixtures under tests/fixtures/ (sample.mov, sample.mp4, sample.livp). End-to-end conversion tests require FFmpeg.
Development
pip install -e ".[dev]"
pytest
black src/ tests/
ruff check src/ tests/
Technical details
- Input: MOV, MP4, M4V, or
.livp(any video codec FFmpeg can decode) - Output: Animated GIF (GIF89a) with optimized 256-color palette
- Defaults: 15 fps, 480px max width, infinite loop
- Scaling: Lanczos; dithering: Bayer
- Optimization: Two-pass
palettegen/paletteuse
License
MIT. See LICENSE.
Metadata
Release files for livephoto-to-gif 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| livephoto_to_gif-0.1.0.tar.gz | 12.6 kB | Without provenance | Details for livephoto_to_gif-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| livephoto_to_gif-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for livephoto_to_gif-0.1.0-py3-none-any.whl |
Total release size: 21.6 kB
Release files / livephoto_to_gif-0.1.0.tar.gz
| Download URL | livephoto_to_gif-0.1.0.tar.gz |
|---|---|
| Size | 12.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
481eb8c1e07c1477f48db3952fa91f5eaf90665297e9ccc6346700fbb63940c2
|
|
BLAKE2b-256 checksum How to use checksums |
ff5158b37a4b6f5d9aae2c7d752de6a6d836fcd5f4045fe90f159289ba9e473d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / livephoto_to_gif-0.1.0-py3-none-any.whl
| Download URL | livephoto_to_gif-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
96f837a48712c39f5d171903efc2ab42d1958a2c079f2fd650fa2e14652a2941
|
|
BLAKE2b-256 checksum How to use checksums |
535520fb092d9cbb4d82ddaeca3851e0bc82f1702a0d9a8e8d8b0f0a308f3109
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for livephoto-to-gif 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.