Skip to content

refactor(media-duration): replace moviepy with mutagen and pymediainfo

Refactoring Request Template

Title (semantic)

refactor(media-duration): replace moviepy with mutagen and pymediainfo


Description

This merge request refactors media duration extraction by replacing MoviePy with lightweight metadata-based libraries.

Changes Made

  • Removed MoviePy dependency from app/utils/media_duration.py
  • Replaced audio duration extraction with Mutagen
  • Replaced video duration extraction with PyMediaInfo
  • Removed ffmpeg subprocess fallback and re-encoding logic
  • Simplified duration extraction to use metadata headers instead of decoding media
  • Preserved existing function behavior/API for backward compatibility
  • Improved error handling for unsupported or corrupted media files
  • Removed unused imports and dead code related to MoviePy

Dependency Updates

Updated pyproject.toml:

Removed:

  • moviepy

Added:

  • mutagen
  • pymediainfo

Benefits

  • Reduced dependency weight
  • Faster duration extraction
  • Cleaner implementation
  • Eliminated hidden ffmpeg dependency
  • Improved maintainability and reliability

Checklist

  • Code has been refactored for clarity, maintainability, or performance
    • No functional changes have been introduced
    • Existing behavior/API preserved
    • All existing tests are passing
    • Code adheres to project coding standards
    • Removed unnecessary dependencies and dead code

Related Issue(s)

Closes #102

Merge request reports

Loading