Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Abimael10/scut

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scut - Simple Cut

A fast, precise MP3 cutting tool built with Rust.

Features

  • Frame-accurate MP3 cutting using ffmpeg stream copy
  • Minimal memory usage (constant, independent of file size)
  • Supports MM:SS and SS time formats
  • Auto-generates timestamped output filenames

Prerequisites

  • Rust 1.70+
  • ffmpeg (must be installed)

Installing ffmpeg

# Ubuntu/Debian
sudo apt install ffmpeg

# macOS
brew install ffmpeg

# Arch Linux
sudo pacman -S ffmpeg

# Or download from: https://ffmpeg.org/download.html

Installation

cargo build --release
# Binary: target/release/scut

How It Works

  1. You specify an MP3 file on your computer (e.g., podcast.mp3)
  2. You tell scut where to start and stop cutting (e.g., from 1:23 to 5:45)
  3. scut creates a new MP3 file with just that segment
  4. Your original file is never modified

The tool reads directly from your file, no uploading or loading into memory required.

Usage

Basic Example

# Cut from 1 minute 23 seconds to 5 minutes 45 seconds
cargo run -- -i /path/to/podcast.mp3 -s 1:23 -e 5:45

# IMPORTANT: Quote paths with spaces or special characters
cargo run -- -i "/path/with spaces/song.mp3" -s 1:23 -e 5:45

What happens:

  • Reads: /path/to/podcast.mp3
  • Extracts: Audio from 1:23 to 5:45
  • Creates: podcast_cut_20250114_143022.mp3 (in current directory)

Important: Handling Special Characters

Always quote file paths that contain:

  • Spaces
  • Parentheses ()
  • Brackets []
  • Special characters
# ✅ Correct (quoted)
cargo run -- -i "/path/Song (2024) [HD].mp3" -s 1:00 -e 2:00

# ❌ Wrong (unquoted - bash will fail)
cargo run -- -i /path/Song (2024) [HD].mp3 -s 1:00 -e 2:00

Specify Output Location

# Save with custom name
cargo run -- -i "/path/to/podcast.mp3" -s 1:23 -e 5:45 -o intro.mp3

# Save to specific folder (folder must exist)
cargo run -- -i "/path/to/podcast.mp3" -s 1:23 -e 5:45 -o "/path/to/output/intro.mp3"

Using Seconds Instead of Minutes

# 90 seconds to 180 seconds (same as 1:30 to 3:00)
cargo run -- -i /path/to/song.mp3 -s 90 -e 180

All Options

-i, --input <FILE>   Path to your MP3 file (e.g., /home/user/music.mp3)
-s, --start <START>  Start time: MM:SS (e.g., 1:23) or seconds (e.g., 83)
-e, --end <END>      End time: MM:SS (e.g., 5:45) or seconds (e.g., 345)
-o, --output <FILE>  Where to save (optional, defaults to timestamped name)

Real-World Examples

# Extract first 30 seconds of a song
cargo run -- -i song.mp3 -s 0:00 -e 0:30 -o preview.mp3

# Cut a 10-minute segment from a lecture
cargo run -- -i lecture.mp3 -s 15:00 -e 25:00 -o chapter2.mp3

# Remove intro from podcast (get everything from 1:30 to end)
# First check duration: ffprobe -i podcast.mp3 -show_entries format=duration -v quiet
cargo run -- -i podcast.mp3 -s 1:30 -e 45:00 -o no_intro.mp3

Architecture

Module structure following SOLID principles:

  • errors.rs - Error types
  • time.rs - Time parsing and validation
  • cli.rs - CLI argument parsing
  • audio.rs - Audio cutting operations
  • main.rs - Application orchestration

Each module has a single responsibility and minimal public API.

Testing

cargo test  # 27 unit tests

Tests were written before implementation (TDD approach).

License

MIT

About

A fast, precise MP3 cutting tool built with Rust.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages