Skip to main content

High-performance Python library for slicing and converting audio/video files with zero bloat

Project description

🫧 Nitrox

Deep, fast, clean. Media processing at maximum depth.

Nitrox is a Python library for high performance audio and video processing. Built on ffmpeg with a clean, intuitive API.

Installation

pip install nitrox

With audio processing:

pip install nitrox[audio]

FFmpeg Requirement

Nitrox requires ffmpeg to be installed on your system.

macOS:

# Using Homebrew
brew install ffmpeg

Linux (Ubuntu/Debian):

sudo apt update
sudo apt install ffmpeg

Linux (RHEL/CentOS):

sudo dnf install ffmpeg
# or
sudo yum install ffmpeg

Other platforms: Download from ffmpeg.org

Quick Start

from nitrox import Media

# Basic usage
Media("input.mp4").slice(10, 30).to("output.mp4")

# Audio extraction
Media("video.mp4").extract_audio().to("audio.wav")

# Video processing
Media("input.mp4").resize(720, 480).to("resized.mp4")

Minimal Syntax

For power users, Nitrox offers an ultra-minimal X alias:

from nitrox import X

# Same functionality, minimal syntax
X("input.mp4")[10:30].to("output.mp4")
X("video.mov").extract_audio().to("audio.mp3")

Core Features

Intuitive Slicing

media = Media("video.mp4")

# Time-based slicing
media[0:10]              # First 10 seconds
media[30:60]             # From 30s to 60s
media[10:]               # From 10s to end
media[:30]               # First 30 seconds

Chainable Operations

# Video processing
Media("input.mp4") \
    .slice(10, 60) \
    .resize(1280, 720) \
    .to("processed.mp4")

# Audio processing
Media("audio.wav") \
    .normalize_audio() \
    .fade_in(1.0) \
    .fade_out(2.0) \
    .to("clean.wav")

Audio Processing

# Basic audio operations
Media("input.mp3").resample(44100).to("output.wav")
Media("stereo.wav").to_mono().to("mono.wav")

# With numpy integration
audio_data = Media("song.wav")[10:20].to_numpy()
Media.from_numpy(audio_data, 44100).to("processed.wav")

Examples

Extract Highlights

# Extract multiple clips
video = Media("long_video.mp4")
highlights = [
    video[0:30],      # Opening
    video[300:330],   # Middle segment  
    video[1200:1230]  # Ending
]

for i, clip in enumerate(highlights):
    clip.to(f"highlight_{i}.mp4")

Podcast Processing

# Clean up podcast audio
Media("raw_recording.wav") \
    .normalize_audio() \
    .fade_in(0.5) \
    .fade_out(1.0) \
    .to("podcast_ready.mp3")

Batch Processing

# Process multiple files
import os

for filename in os.listdir("raw_videos/"):
    if filename.endswith('.mp4'):
        Media(f"raw_videos/{filename}") \
            .resize(720, 480) \
            .to(f"processed/{filename}")

API Reference

Core Operations

Video:

  • resize(width, height) - Resize video
  • crop(x, y, width, height) - Crop video
  • set_fps(fps) - Change frame rate

Audio:

  • extract_audio() - Extract audio track
  • normalize_audio() - Normalize audio levels
  • resample(rate) - Change sample rate
  • to_mono() - Convert to mono
  • fade_in(duration) - Add fade in
  • fade_out(duration) - Add fade out

Slicing:

  • slice(start, end) - Extract time range
  • [start:end] - Python slice notation

Output:

  • to(path) - Save processed media
  • to_numpy() - Extract as numpy array (requires numpy)
  • from_numpy(data, rate) - Create from numpy array (requires numpy)

Utility:

  • info() - Get media information
  • preview_command() - Show ffmpeg command

Command Line

# Basic usage
nitrox slice input.mp4 output.mp4 --start 10 --end 30
nitrox resize video.mp4 small.mp4 --width 720 --height 480
nitrox convert video.mp4 audio.mp3 --extract-audio

# Get media info
nitrox info video.mp4

Requirements

  • Python 3.8+
  • ffmpeg (see installation instructions above)
  • numpy (optional, for array processing)

License

MIT License - see LICENSE file.


**🫧 Nitrox **

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

nitrox-0.1.0.tar.gz (24.7 kB view details)

Uploaded Source

Built Distribution

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

nitrox-0.1.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file nitrox-0.1.0.tar.gz.

File metadata

  • Download URL: nitrox-0.1.0.tar.gz
  • Upload date:
  • Size: 24.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for nitrox-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ad75b8c1bcb7701e0b1d9d93bdf5688d95195bd4cb8e046c31b24cc6189156b8
MD5 45568e94538e019a8cf65a8f50cc5c35
BLAKE2b-256 1db6f1055bf991a56157eecc397fe923474e6471d1f1ab282c5b62567ec96219

See more details on using hashes here.

File details

Details for the file nitrox-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nitrox-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for nitrox-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad76481c094ebe663ba577d5fb785d7ca3ec392d104ff2a2c82b10f6c80602ab
MD5 c01ee952dbe7f3d86a8e5f1c4172b1aa
BLAKE2b-256 74782b9d515f3477ad1afd2ed1b745c919c516ba4e3ea9bc35801c91c1b38989

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