Skip to content

Commit 0b2300c

Browse files
m_igashim_igashi
authored andcommitted
feat: add clipping prevention, recursive dirs, JSON output, dry-run, progress bar
- Add -k option to prevent clipping by automatically limiting gain - Add -R option for recursive directory processing - Add -o json option for JSON output format - Add -n/--dry-run option to preview changes without modifying files - Add progress bar for batch operations (5+ files) - Update README with new features and examples Closes #3, #4, #5, #6, #7
1 parent ebdbfcb commit 0b2300c

File tree

3 files changed

+954
-132
lines changed

3 files changed

+954
-132
lines changed

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mp3rgain"
3-
version = "0.5.0"
3+
version = "0.6.0"
44
edition = "2021"
55
authors = ["Masanari Higashi <M-Igashi@users.noreply.github.com>"]
66
description = "Lossless MP3 volume adjustment - a modern mp3gain replacement written in Rust"
@@ -19,6 +19,9 @@ replaygain = ["symphonia"]
1919
anyhow = "1.0"
2020
colored = "2.0"
2121
symphonia = { version = "0.5", optional = true, default-features = false, features = ["mp3"] }
22+
serde = { version = "1.0", features = ["derive"] }
23+
serde_json = "1.0"
24+
indicatif = "0.17"
2225

2326
[lib]
2427
name = "mp3rgain"

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,63 @@ mp3rgain -a *.mp3
9696
mp3rgain -u song.mp3
9797
```
9898

99+
### Clipping prevention
100+
101+
```bash
102+
# Automatically reduce gain if clipping would occur
103+
mp3rgain -k -g 5 song.mp3
104+
# Output: gain reduced from 5 to 3 steps to prevent clipping
105+
106+
# With ReplayGain
107+
mp3rgain -k -r song.mp3
108+
```
109+
110+
### Recursive directory processing
111+
112+
```bash
113+
# Process all MP3s in a directory recursively
114+
mp3rgain -R /path/to/music
115+
mp3rgain -g 2 -R /path/to/music
116+
mp3rgain -r -R /path/to/album
117+
```
118+
119+
### Dry-run mode
120+
121+
```bash
122+
# Preview changes without modifying files
123+
mp3rgain -n -g 2 *.mp3
124+
mp3rgain --dry-run -r *.mp3
125+
```
126+
127+
### JSON output
128+
129+
```bash
130+
# Output in JSON format for scripting
131+
mp3rgain -o json song.mp3
132+
133+
# Combine with other options
134+
mp3rgain -o json -r *.mp3
135+
```
136+
137+
Example JSON output:
138+
```json
139+
{
140+
"files": [
141+
{
142+
"file": "song.mp3",
143+
"mpeg_version": "MPEG1",
144+
"channel_mode": "Joint Stereo",
145+
"frames": 5765,
146+
"min_gain": 89,
147+
"max_gain": 217,
148+
"avg_gain": 168.2,
149+
"headroom_steps": 38,
150+
"headroom_db": 57.0
151+
}
152+
]
153+
}
154+
```
155+
99156
## Command-Line Options
100157

101158
| Option | Description |
@@ -108,7 +165,11 @@ mp3rgain -u song.mp3
108165
| `-s c` | Check/show file info (analysis only) |
109166
| `-p` | Preserve original file timestamp |
110167
| `-c` | Ignore clipping warnings |
168+
| `-k` | Prevent clipping (automatically limit gain) |
111169
| `-q` | Quiet mode (less output) |
170+
| `-R` | Process directories recursively |
171+
| `-n`, `--dry-run` | Dry-run mode (show what would be done) |
172+
| `-o <fmt>` | Output format: `text` (default) or `json` |
112173
| `-v` | Show version |
113174
| `-h` | Show help |
114175

0 commit comments

Comments
 (0)