A lightweight C# .NET 9 console application that automatically splits a long MP3 file into individual songs using silence detection powered by FFmpeg.
It finds silent gaps between songs, extracts each track losslessly (no re-encoding), and saves them as separate MP3 files with a CSV manifest.
Ideal for DJ mixes, continuous albums, or any long recordings.
- 🎵 Detects silence gaps between songs automatically
- ⚡ Splits MP3s without quality loss (stream-copy mode)
- 📊 Generates a CSV manifest with timestamps
- 🧠 Adjustable parameters (
--silenceDb,--minSilence,--minTrack,--pad) - 💻 Cross-platform — runs on Windows, macOS, or Linux (requires FFmpeg)
- 🪶 Written in pure .NET 9 C#, no external NuGet dependencies
| Component | Purpose | Installation |
|---|---|---|
| .NET 9 SDK | Run/build the console app | Download .NET 9 |
| FFmpeg | Detect & cut silence | Download FFmpeg or winget install Gyan.FFmpeg |
After installing FFmpeg, verify it’s on your PATH:
ffmpeg -version
ffprobe -versionClone this repo:
git clone https://github.com/<your-username>/SplitBySilence.git
cd SplitBySilenceBuild it:
dotnet builddotnet run --project SplitBySilence.csproj -- --input "C:\music\long_mix.mp3"This will:
- Detect silences (default: quieter than -35 dB for ≥ 1.5 s)
- Split tracks
- Save them in a folder next to the input, e.g.
long_mix_split/ - Generate
long_mix_tracks.csvwith segment info
| Option | Default | Description |
|---|---|---|
--input |
(required) | Path to input MP3 file |
--outdir |
auto | Output directory |
--silenceDb |
-35 |
Silence threshold (lower = more sensitive) |
--minSilence |
1.5 |
Minimum silence duration (seconds) |
--minTrack |
60 |
Minimum valid track length (seconds) |
--pad |
0.0 |
Add/subtract seconds to cut edges |
--ffmpeg |
ffmpeg |
Custom path to ffmpeg |
--ffprobe |
ffprobe |
Custom path to ffprobe |
--dry-run |
— | Detect & show planned splits (no files written) |
--verbose |
— | Print detailed detection logs |
Example:
dotnet run --project SplitBySilence.csproj -- \
--input "C:\mixes\session.mp3" \
--silenceDb -40 \
--minSilence 2.0 \
--minTrack 75 \
--pad 0.15📁 long_mix_split/
├── long_mix_track_01.mp3
├── long_mix_track_02.mp3
├── long_mix_track_03.mp3
├── ...
└── long_mix_tracks.csv
The CSV manifest contains:
Index,Start,End,Duration,File
1,0.0,243.5,4:03,long_mix_track_01.mp3
2,243.5,496.2,4:13,long_mix_track_02.mp3
...
-
FFmpeg “silencedetect” filter analyzes the waveform:
silencedetect=noise=-35dB:d=1.5 -
Logs silence start/end points → parsed by C#
-
Segments are computed and exported via
ffmpeg -ss -to -c copy(no re-encode)
This ensures frame-accurate, lossless MP3 cuts.
-
Install Visual Studio Code
-
Open folder:
code . -
Press
F5to build & run (launch config included in.vscode/launch.json)
You can package it for Windows:
dotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=trueOutput:
bin\Release\net9.0\win-x64\publish\SplitBySilence.exe
Then you can run:
SplitBySilence.exe --input "C:\music\album.mp3"- Lower
--silenceDb(e.g.-40) if silences aren’t detected. - Increase
--minSilence(e.g.2.0) to avoid false splits. - Use
--dry-run --verboseto preview detection logs before cutting. - Works with WAV, FLAC, or other formats too — just change the file extension.
Majid — Software Developer & Solution Architect 🔗 LinkedIn • 💻 [.NET / Blazor / FFmpeg enthusiast]
This project is licensed under the MIT License — free to use, modify, and distribute.
If you find this helpful, please ⭐ the repo — it helps others discover it!
