Skip to main content

a cli tool to remove music from videos

Project description

Video Music Remover

GitHub License PyPI - Python Version PyPI - Version Static Badge

A powerful Python tool to remove background music from videos while preserving speech and other sounds using advanced machine learning models.

Overview

Video Music Remover is a command-line tool that uses the powerful demucs machine learning model to separate and remove music from videos while preserving speech, sound effects, and other audio elements. This is particularly useful for Muslim people and anyone who needs to remove music from videos.

The tool automatically processes all audio tracks in the input file, making it ideal for videos with multiple language tracks or commentary audio tracks.

Features

  • Batch Processing: Process multiple videos in a directory with a single command
  • Multiple ML Models: Choose from different machine learning models based on your needs
  • Preserves Video Quality: Maintains the original video quality while only modifying the audio
  • Multiple Audio Tracks Support: Automatically processes all audio tracks in the input video
  • Simple CLI Interface: Easy-to-use command-line interface
  • Logging Support: Optional logging for tracking processing progress
  • Original File Management: Option to delete original files after processing

Supported Formats

Video Formats

  • MP4 (.mp4)
  • Matroska (.mkv)
  • WebM (.webm)

Machine Learning Models

  • demucs/htdemucs (default): First version of Hybrid Transformer Demucs
  • demucs/htdemucs_ft: Fine-tuned version of htdemucs (4x slower but potentially better quality)
  • demucs/mdx: Trained only on MusDB HQ, winning model on track A at the MDX challenge
  • demucs/mdx_extra: Trained with extra training data, ranked 2nd on track B of the MDX challenge

System Requirements

  • Python 3.10 or higher
  • FFmpeg (required for audio/video processing)
  • Sufficient disk space for temporary files during processing

Installation

Using pip

pip install video-music-remover

Using UV (recommended)

uv tool install video-music-remover

Usage

Basic Usage

To remove music from a single video:

video-music-remover remove-music input_video.mp4 output_directory/

To process all supported videos in a directory:

video-music-remover remove-music input_directory/ output_directory/

Advanced Options

Specify a different machine learning model:

video-music-remover remove-music input_video.mp4 output_directory/ --model ht_demucs_ft

Enable logging to a file:

video-music-remover remove-music input_video.mp4 output_directory/ --log processing.log

Delete original files after successful processing:

video-music-remover remove-music input_video.mp4 output_directory/ --delete-original

Health Check

Verify that all dependencies are correctly installed:

video-music-remover health-check

For detailed debugging information:

video-music-remover health-check --debug

Version Information

Display the installed version:

video-music-remover version

How It Works

The program processes videos through the following steps:

  1. Audio Extraction: Extracts all audio tracks from the input video
    • if input is file, the new video file in the output directory will be replaced if exists
    • if input is a directory, only supported files that doesn't exist in the output directory will be processed
  2. Music Separation: Uses the selected demucs model to separate vocals from music in all extracted audio tracks
  3. Audio Processing: Preserves the vocal tracks and removes the music tracks
  4. Video Reconstruction: Creates a new video with the original video track and the processed audio tracks while preserving other streams and metadata
  5. Original File Handling: Optionally deletes original files when using --delete-original

The resulting video will have the same visual quality but with background music removed while preserving speech and other sounds.

Development Setup

Package Manager

This project uses UV as its package manager for development.

Setting Up Development Environment

  1. Clone the repository:

    git clone https://github.com/asaah18/video-music-remover.git
    cd video-music-remover
    
  2. Create a virtual environment and install dependencies:

    uv venv
    uv sync
    

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

video_music_remover-1.1.2.tar.gz (56.8 kB view details)

Uploaded Source

Built Distribution

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

video_music_remover-1.1.2-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file video_music_remover-1.1.2.tar.gz.

File metadata

  • Download URL: video_music_remover-1.1.2.tar.gz
  • Upload date:
  • Size: 56.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.19

File hashes

Hashes for video_music_remover-1.1.2.tar.gz
Algorithm Hash digest
SHA256 2d64b1abd2f05324b3b9fbf1ed8b875a53e264751a29ddda779b45ff5cee220f
MD5 93f534d281efe9aa6596604914556a5a
BLAKE2b-256 9152ec3b2facf06043f90c697083f648025a296bf5e42501a29696bd6328dd6a

See more details on using hashes here.

File details

Details for the file video_music_remover-1.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for video_music_remover-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 88875ccdc883504374a21417fc5e48a7e69c2d088077907432e2a7002e97f50b
MD5 1be1254fd3fa78f1f3a969d666aa86cd
BLAKE2b-256 677ee39373fe1abcf57a62bb8d90f9095d1eacdf7da9e39577cb0865b8877488

See more details on using hashes here.

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