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.3.tar.gz (56.9 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.3-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for video_music_remover-1.1.3.tar.gz
Algorithm Hash digest
SHA256 99cd1d25227bdb008dde64e790a8c6484e2acffb875b63075ae43f992d68e52e
MD5 3dbf0de52a19d033308dd62b35c4b794
BLAKE2b-256 65a43a05ba691eb32ad4831bab2a83bf6721812a8044f18a3317b8656c2568b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for video_music_remover-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6e1321275d2d95c66ffb0d648d0665799a704d05fc3c64a173ba7e78cdb3395c
MD5 ea4579a2457b64bdd4ab60ece23cbdaf
BLAKE2b-256 4a3d5f63260e1826caac69bcc9d1a54c203d5ead7209f7b3f78d56282e246dcd

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