iPhone Media Convert

A lightweight Python utility suite for organizing and converting media exported from iPhones and other Apple devices. This project solves two common issues encountered when transferring media from iOS devices to Windows or Linux systems: a) HEIC image compatibility problems b) Large MOV video files and codec compatibility issues

python ffmpeg pillow
View on GitHub

iPhone Media Convert

A lightweight Python utility suite for organizing and converting media exported from iPhones and other Apple devices.

This project solves two common issues encountered when transferring media from iOS devices to Windows or Linux systems:

  1. HEIC image compatibility problems
  2. Large MOV video files and codec compatibility issues

The repository provides two standalone utilities:


Features

Media Organization

The move_media.py utility:

Supported image formats:

Supported video formats:


Media Conversion

The convert_media.py utility:

Image Conversion

Video Conversion


Why This Project Exists

Modern iPhones use:

These formats are efficient but can create workflow issues:

Problem Example
HEIC unsupported Some Windows apps cannot preview HEIC
Large video sizes iPhone videos consume large storage quickly
Limited compatibility Some media players dislike MOV containers
Upload issues Some websites reject HEIC uploads
Media server issues Jellyfin/Plex workflows may require transcoding

This project automates the cleanup and conversion process.


Project Structure

.
├── convert_media.py
├── move_media.py
├── readme.md
└── .gitignore

Requirements

Python Version


Python Dependencies

Install dependencies using pip:

pip install Pillow pillow-heif

FFmpeg

FFmpeg is required for video conversion.

Linux

Ubuntu / Debian:

sudo apt install ffmpeg

Arch Linux:

sudo pacman -S ffmpeg

Fedora:

sudo dnf install ffmpeg

Windows

You can install FFmpeg using:

Winget

winget install Gyan.FFmpeg

Chocolatey

choco install ffmpeg

The script also attempts to automatically detect FFmpeg in common Windows installation locations.


Installation

Clone Repository

git clone https://github.com/yourusername/iPhoneMediacovert.git
cd iPhoneMediacovert

Create Virtual Environment (Recommended)

Linux / macOS

python3 -m venv venv
source venv/bin/activate

Windows

python -m venv venv
venv\Scripts\activate

Install Dependencies

pip install Pillow pillow-heif

Usage

1. Organize Media Files

Move all images and videos into separate folders:

python move_media.py

This creates:

Images/
Videos/

and automatically moves supported files.


Organize a Specific Folder

python move_media.py /path/to/media

Example:

python move_media.py ~/Downloads/iPhoneExport

2. Convert Media Files

Convert all supported media inside the current folder:

python convert_media.py

Command Line Arguments

The convert_media.py script supports several optional arguments for customization.

Positional Argument

root

Root folder containing the Images/ and Videos/ directories.

Default:

.

Example:

python convert_media.py ~/Pictures/iPhoneBackup

The folder structure must look like:

root/
├── Images/
└── Videos/

Optional Arguments

--jpg-quality

Controls JPEG quality for converted HEIC images.

Default:

95

Example:

python convert_media.py --jpg-quality 85

Lower values:

Higher values:


--ffmpeg

Specify a custom FFmpeg executable path.

Default:

ffmpeg

Example:

Linux

python convert_media.py --ffmpeg /usr/bin/ffmpeg

Windows

python convert_media.py --ffmpeg "C:\ffmpeg\bin\ffmpeg.exe"

Useful when:


Full Usage Examples

Basic Conversion

python convert_media.py

Convert Another Folder

python convert_media.py ~/Media/iPhoneExport

Lower JPEG Quality

python convert_media.py --jpg-quality 80

Custom FFmpeg Binary

python convert_media.py --ffmpeg /opt/ffmpeg/bin/ffmpeg

Combined Example

python convert_media.py ~/Media/iPhoneExport --jpg-quality 88 --ffmpeg /usr/bin/ffmpeg

This command:


Convert Media in Another Folder

python convert_media.py /path/to/media

Example:

python convert_media.py ~/Pictures/iPhoneBackup

Conversion Details

HEIC → JPG

The script:

  1. Opens the HEIC image
  2. Decodes it using pillow-heif
  3. Converts it to RGB
  4. Saves a .jpg version

Example:

IMG_0001.HEIC
↓
IMG_0001.jpg

MOV → MKV

The script:

  1. Uses FFmpeg
  2. Re-encodes video to H.265 / HEVC
  3. Wraps output inside MKV container

Example:

VID_0001.MOV
↓
VID_0001.mkv

Benefits:


Example Workflow

Typical iPhone Export Cleanup

Step 1 — Copy media from iPhone

DCIM/

contains:

IMG_1001.HEIC
IMG_1002.HEIC
VID_1003.MOV
VID_1004.MOV

Step 2 — Organize media

python move_media.py ./DCIM

Result:

DCIM/
├── Images/
│   ├── IMG_1001.HEIC
│   └── IMG_1002.HEIC
└── Videos/
    ├── VID_1003.MOV
    └── VID_1004.MOV

Step 3 — Convert media

python convert_media.py ./DCIM

Result:

IMG_1001.jpg
IMG_1002.jpg
VID_1003.mkv
VID_1004.mkv

Error Handling

The project includes:


Platform Support

Platform Supported
Windows Yes
Linux Yes
macOS Yes

Technical Notes

Libraries Used

Pillow

Used for:


pillow-heif

Adds HEIC/HEIF support to Pillow.


FFmpeg

Used for:


Potential Improvements

Future enhancements may include:


Troubleshooting

FFmpeg Not Found

Install FFmpeg and ensure it is available in PATH.

Verify:

ffmpeg -version

HEIC Conversion Fails

Ensure dependencies are installed correctly:

pip install --upgrade Pillow pillow-heif

Permission Errors

Make sure:


Performance Considerations

Video transcoding is CPU intensive.

Factors affecting speed:

Large 4K iPhone videos may take significant time to process.


Security Notes

This project:


License

Add your preferred license here.

Example:

MIT License

Contributing

Contributions are welcome.

Potential areas:


Acknowledgements


Author

Created for simplifying iPhone media management workflows on desktop systems.