Skip to content

[Feature] Add Live Photo Support for Cross-Platform Transfer #2488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

arrenxxxxx
Copy link

@arrenxxxxx arrenxxxxx commented May 31, 2025

[Feature] Add Live Photo Support for Cross-Platform Transfer

🎯 Overview

This PR implements Live Photo support for LocalSend, enabling the preservation of Apple's Live Photos when transferring files to iOS devices. Live Photos capture not just a moment, but the moments just before and after, bringing memories to life with movement and sound - making them far more vivid and emotionally engaging than static images.

💡 Why Live Photos Matter

Live Photos represent a revolutionary way to capture and preserve memories. Unlike traditional static photos, Live Photos:

  • Capture Living Moments: Record 1.5 seconds before and after the shutter press
  • Preserve Emotional Context: Include ambient sounds and subtle movements
  • Enhance Memory Recall: Studies show that motion and sound significantly improve memory retention
  • Future-Proof Memories: Maintain the full richness of captured moments for future generations

By supporting Live Photo transfer, LocalSend ensures that these precious, dynamic memories are preserved when sharing between devices, rather than being reduced to static images.

📋 Summary

  • Live Photo Reception: Receive and save Live Photos on iOS devices
  • Intelligent File Pairing: Automatic matching of image and video components based on filename
  • Smart Caching System: Temporary storage and pairing of Live Photo components with timeout management
  • User Interface Integration: Toggle option for saving as Live Photo in receive settings (only shown on supported devices)
  • Device Capability Detection: Automatic detection of Live Photo support with graceful UI adaptation
  • Seamless Integration: Works with existing LocalSend transfer protocols

🔧 Key Changes

Core Architecture

  • Live Photo Provider: app/lib/provider/live_photo_provider.dart - Device capability detection
  • Caching System: app/lib/provider/cache/live_photo_cache_provider.dart - Intelligent file pairing with timeout management
  • Native Bridge: app/lib/util/native/live_photo_helper.dart - iOS native method calls

iOS Implementation

  • Live Photo Handler: Complete iOS Photos framework integration
  • Metadata Processing: Proper EXIF and QuickTime metadata handling
  • Video Processing: H.264 encoding with original bitrate preservation
  • Error Handling: Comprehensive error logging and recovery

File Pairing Logic

The system uses filename-based matching to identify Live Photo pairs:

  1. Filename Extraction: Remove file extensions to get base filename
  2. Component Matching: Match image files (.HEIC, .JPG) with video files (.MOV, .MP4) that share the same base name
  3. Automatic Pairing: When both components are received, automatically combine them into a Live Photo
  4. Timeout Protection: If pairing fails within 5 minutes, files are saved separately to prevent data loss

Example: IMG_1234.HEIC + IMG_1234.MOV → Combined into Live Photo

UI/UX Enhancements

  • Smart UI Adaptation: "Save as Live Photo" toggle only appears on devices that support Live Photo functionality
  • Receive Options: New "Save as Live Photo" toggle in receive settings (iOS only)
  • Settings Integration: Persistent user preferences
  • Internationalization: Support for English and Chinese languages
  • Graceful Degradation: On unsupported devices, the Live Photo option is completely hidden from the UI

🚀 How to Test

Prerequisites

  • iOS device with Live Photos capability (iOS 12+)
  • Any device capable of sending files to LocalSend
  • LocalSend installed on both devices

Test Scenarios

  1. Live Photo Reception:

    • Send paired image and video files with matching filenames from any device
    • Receive on iOS device with "Save as Live Photo" enabled
    • Verify Live Photo is created and saved correctly in Photos app
  2. UI Adaptation:

    • Install on iOS device: Verify "Save as Live Photo" option appears in receive settings
    • Install on Android/other devices: Verify "Save as Live Photo" option is completely hidden
  3. Settings Persistence:

    • Toggle "Save as Live Photo" option on iOS
    • Restart app and verify setting is preserved
  4. Fallback Behavior:

    • Send only image or only video file
    • Verify files are saved separately when pairing fails

📱 Platform Support

Platform Sending Receiving UI Option Visibility
iOS 12+ ❌ Not Yet ✅ Full Support ✅ "Save as Live Photo" shown
Android ❌ Not Supported ❌ Not Supported ❌ Option completely hidden
Windows/macOS/Linux ❌ Not Supported ❌ Not Supported ❌ Option completely hidden

Current Limitation: This initial implementation focuses on receiving Live Photos on iOS devices. Sending Live Photos from iOS and Android support are planned for future releases.

🎬 Demo Materials

Screenshots

  1. Not support save as Live Photo
    1  not support save as livephoto
  2. IOS support save as Live Photo
    1  ios support live photo
  3. Receive
    ios receive option page
    ios receive result
    ios gallory

Demo Gif

ios live photo receive page

🔄 How to Extend

Supporting Android Platforms

To add Android Live Photo support, developers need to:

  1. Research Android Live Photo Formats: Different manufacturers use different formats (Samsung Motion Photos, Google Motion Photos, etc.)

  2. Implement Android Native Code: Add Live Photo saving capabilities in the Android MainActivity.kt

  3. Update Device Detection Logic: Extend the capability detection to include Android devices

  4. Add Method Channel Handlers: Implement Android-specific method channels for Live Photo operations

  5. Test Across Devices: Validate functionality across different Android manufacturers and versions

The existing architecture with LivePhotoHelper and LivePhotoCacheProvider is designed to be extensible and will automatically support Android once the native implementation is added.

⚠️ Known Limitations

Current Constraints

  • iOS Reception Only: Currently only supports receiving Live Photos on iOS devices
  • Manual File Pairing: Requires sender to manually select both image and video components
  • Filename Dependency: Relies on matching filenames for component pairing
  • No Live Photo Preview: Cannot preview Live Photos during transfer selection

Device Compatibility

  • Fully Supported: iOS 12+ devices for reception
  • Partially Supported: Any device can send component files
  • Unsupported: Android Live Photo creation, iOS Live Photo sending
  • UI Behavior: Live Photo options are completely hidden on unsupported devices

Outstanding Issues

  • Transfer Progress Accuracy: When merging image and video files into Live Photos, the process blocks the sending thread, causing inaccurate estimated completion times displayed on both sender and receiver UI. The progress indicators may show misleading time estimates during the Live Photo processing phase, though they will not show completion until the actual Live Photo creation is finished.

🔮 Future Roadmap

Planned Enhancements

  • Complete Documentation: Comprehensive user guides and developer documentation for Live Photo functionality
  • Android Live Photo Support: Implement receiving and saving Live Photos on Android devices with support for various manufacturer formats
  • iOS Live Photo Sending: Enable sending Live Photos from iOS devices, including proper export and component separation
  • Fix Transfer Progress Accuracy: Resolve UI progress estimation issues caused by Live Photo processing blocking the sending thread

📦 Attachments

Download: ios_localsend_livephoto.zip

🔗 Related Issues


Note: This is the first phase of Live Photo support, focusing on iOS reception capabilities. The implementation follows LocalSend's architecture patterns and maintains backward compatibility while laying the foundation for comprehensive Live Photo support across all platforms.

@arrenxxxxx arrenxxxxx changed the title Feature/1.0.0 livephototransfer [Feature] Add Live Photo Support for Cross-Platform Transfer May 31, 2025
@arrenxxxxx arrenxxxxx force-pushed the feature/1.0.0_livephototransfer branch from f2aadac to c2a6335 Compare June 2, 2025 04:38
@arrenxxxxx arrenxxxxx marked this pull request as ready for review June 2, 2025 06:25
@Tienisto
Copy link
Member

Tienisto commented Jul 9, 2025

Thank you for your PR. I might look into this, when I've done the Rust rewrite of the core network logic. I am not sure if this PR is still valid afterwards (or how this can be adapted).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transfer Apple Live Photos to Android with Localsend [Feature request]: Add export support for ios LivePhotos
2 participants