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.1.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.1-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nitrox-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 77e5c15957af5abd1c55fee788245cde9e2b77d81d8d5274ea7a050a45ca4760
MD5 51c9da32e40443eb427c8c5738f2e751
BLAKE2b-256 6bced9b992f2b4849df32b6f56be793083eb5d5f76975edfb1fad84193dfa9fd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nitrox-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c8554f5423747db0e3a4dfe2bf2f7acf4e124265c71bbd794567ca0c99c9e5f7
MD5 5b0e70d8046ad6b67c23af71357fb305
BLAKE2b-256 d1904f115b54601fb9e6de60774ee41312e00b2f60bea936009175e7105e537e

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