Skip to main content

Extract videos from Google Motion Photos with ease!

Project description

MotionMiner

MotionMiner Logo

Extract videos from Google Motion Photos with ease!

MotionMiner is a powerful Python tool that extracts embedded MP4 videos from Google Motion Photos (JPG files) and converts them to various formats including MP4 and GIF animations.

codecov

๐Ÿš€ Features

  • Extract MP4 videos from Google Motion Photos
  • Convert to GIF animations with customizable quality settings
  • Batch processing for multiple files
  • Multiple output formats: MP4, GIF, or both
  • Quality presets for GIF output (tiny, low, medium, high)
  • File structure analysis to examine Motion Photo internals
  • Cross-platform support (Windows, macOS, Linux)

๐Ÿ“‹ Requirements

  • Python 3.6+
  • FFmpeg (for video conversion)

๐Ÿ› ๏ธ Installation

Method 1: Install from PyPI (Recommended)

pip install motionminer

Method 2: Install from Source

git clone https://github.com/yourusername/motionminer.git
cd motionminer
pip install -e .

Step 2: Install FFmpeg

FFmpeg is required for video processing. Choose your platform:

Windows

  1. Download FFmpeg from https://ffmpeg.org/download.html
  2. Extract to a folder (e.g., C:\ffmpeg)
  3. Add the bin folder to your system PATH
  4. Test installation: ffmpeg -version

macOS

# Using Homebrew
brew install ffmpeg

# Using MacPorts
port install ffmpeg

Linux (Ubuntu/Debian)

sudo apt update
sudo apt install ffmpeg

Linux (CentOS/RHEL/Fedora)

# CentOS/RHEL
sudo yum install ffmpeg

# Fedora
sudo dnf install ffmpeg

Step 3: Verify Installation

Test that everything is working:

motionminer --help

Or use the alternative command:

motion-extract --help

๐ŸŽฏ Usage

Basic Usage

Extract MP4 from a single Motion Photo:

motionminer photo.jpg

Extract as GIF animation:

motionminer photo.jpg --gif

Extract both MP4 and GIF:

motionminer photo.jpg --both

Output Options

Specify custom output filename:

motionminer photo.jpg -o my_video.mp4
motionminer photo.jpg -o my_animation.gif --gif

GIF Quality Settings

MotionMiner offers 4 quality presets for GIF output:

Quality Colors File Size Description
--gif-tiny 64 ~1-2MB Maximum compression
--gif-low 128 ~2-3MB Heavy compression, decent quality
--gif-medium 192 ~3-4MB Balanced quality and size (default)
--gif-high 256 ~5-7MB Best quality

Examples:

motionminer photo.jpg --gif-tiny      # Small file size
motionminer photo.jpg --gif-high      # Best quality

Custom GIF Width

Adjust GIF width (height is automatically calculated):

motionminer photo.jpg --gif --gif-width 640

GIF Looping Control

By default, GIFs loop infinitely. Use --gif-no-loop to create a GIF that plays once:

motionminer photo.jpg --gif --gif-no-loop      # GIF plays once
motionminer photo.jpg --gif-high --gif-no-loop # High quality GIF that plays once

Batch Processing

Process all JPG files in a directory:

motionminer photos/ --batch

Batch process with custom output directory:

motionminer photos/ --batch --batch-output extracted_videos/

Batch convert to GIFs:

motionminer photos/ --batch --gif-low

File Analysis

Analyze Motion Photo structure without extracting:

motionminer photo.jpg --analyze

๐Ÿ“– Command Reference

Required Arguments

  • input - Input JPG file or directory containing JPG files

Optional Arguments

  • -o, --output - Output file path (auto-generated if not provided)
  • --mp4 - Extract as MP4 video (default)
  • --gif - Extract as GIF animation
  • --both - Extract both MP4 and GIF
  • --gif-tiny - Extract as tiny GIF (64 colors, ~1-2MB)
  • --gif-low - Extract as low quality GIF (128 colors, ~2-3MB)
  • --gif-medium - Extract as medium quality GIF (192 colors, ~3-4MB)
  • --gif-high - Extract as high quality GIF (256 colors, ~5-7MB)
  • --gif-width - GIF width in pixels (default: 480)
  • --gif-no-loop - Create GIF that plays once instead of looping infinitely
  • --batch - Process all JPG files in input directory
  • --batch-output - Output directory for batch processing
  • --analyze - Analyze file structure without extracting

๐Ÿ’ก Examples

Single File Examples

# Extract MP4 from Motion Photo
motionminer IMG_20231201_123456.jpg

# Extract high-quality GIF
motionminer IMG_20231201_123456.jpg --gif-high

# Extract GIF that plays once (no loop)
motionminer IMG_20231201_123456.jpg --gif --gif-no-loop

# Extract both formats with custom output
motionminer motion_photo.jpg --both -o my_video.mp4

# Analyze file structure
motionminer motion_photo.jpg --analyze

Batch Processing Examples

# Process all photos in current directory
motionminer . --batch

# Process photos and save to specific directory
motionminer photos/ --batch --batch-output extracted/

# Batch convert to tiny GIFs for web use
motionminer photos/ --batch --gif-tiny --batch-output web_gifs/

# Process with custom GIF settings
motionminer photos/ --batch --gif --gif-width 320 --batch-output small_gifs/

# Batch convert to non-looping GIFs
motionminer photos/ --batch --gif-medium --gif-no-loop --batch-output single_play_gifs/

๐Ÿ”ง Troubleshooting

Common Issues

"No embedded MP4 video found"

  • The file might not be a Google Motion Photo
  • Some Motion Photos have different internal structures
  • Use --analyze to examine the file structure

"FFmpeg not found"

  • Make sure FFmpeg is installed and in your system PATH
  • Test with ffmpeg -version in your terminal

"Permission denied"

  • Check file permissions for input files
  • Ensure you have write permissions in the output directory

Getting Help

View all available options:

motionminer --help

๐Ÿ“ Project Structure

MotionMiner/
โ”œโ”€โ”€ motionminer/        # Main package directory
โ”‚   โ”œโ”€โ”€ __init__.py     # Package initialization
โ”‚   โ”œโ”€โ”€ main.py         # Main application entry point
โ”‚   โ”œโ”€โ”€ cli.py          # Command-line interface
โ”‚   โ”œโ”€โ”€ extractor.py    # Motion Photo extraction logic
โ”‚   โ”œโ”€โ”€ converter.py    # Video conversion utilities
โ”‚   โ”œโ”€โ”€ analyzer.py     # File structure analysis
โ”‚   โ””โ”€โ”€ config.py       # Configuration and settings
โ”œโ”€โ”€ tests/              # Test suite
โ”œโ”€โ”€ pyproject.toml      # Package configuration
โ”œโ”€โ”€ requirements.txt    # Python dependencies
โ””โ”€โ”€ README.md           # This file

๐Ÿค Contributing

Contributions are welcome! Feel free to:

  • Report bugs
  • Suggest new features
  • Submit pull requests
  • Improve documentation

๐Ÿ“„ License

This project is licensed under the terms specified in the LICENSE file.

๐Ÿ™ Acknowledgments

  • Thanks to Google for creating Motion Photos
  • FFmpeg community for excellent video processing tools
  • Python community for amazing libraries

Happy extracting! ๐ŸŽฌโœจ

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

motionminer-1.1.0.tar.gz (264.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

motionminer-1.1.0-py3-none-any.whl (29.0 kB view details)

Uploaded Python 3

File details

Details for the file motionminer-1.1.0.tar.gz.

File metadata

  • Download URL: motionminer-1.1.0.tar.gz
  • Upload date:
  • Size: 264.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for motionminer-1.1.0.tar.gz
Algorithm Hash digest
SHA256 292bd5bf134a51f3ee879879578a5573f8b435cf52ee3da5958ee88fa3f5853f
MD5 ecec4403308a79b78223afb08960507d
BLAKE2b-256 1e05ba17d308ec9bf0bc54d6bd19d5835e4c15823ef65328e3024e3ad1f5543a

See more details on using hashes here.

Provenance

The following attestation bundles were made for motionminer-1.1.0.tar.gz:

Publisher: ci-cd.yml on mlapaglia/MotionMiner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file motionminer-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: motionminer-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 29.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for motionminer-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 43b4b99fda2bad4673b3b266be695e9f99f05ed54cfd8d06672dab5eb7b4740d
MD5 acb4c537ff6320eb898f9e99b834803f
BLAKE2b-256 15221ef81f0f6ff76deba1660f16ea01a0007097eeae1b5958b37f1bbe520bdb

See more details on using hashes here.

Provenance

The following attestation bundles were made for motionminer-1.1.0-py3-none-any.whl:

Publisher: ci-cd.yml on mlapaglia/MotionMiner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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