Repository navigation
How Files Are Clipped
What a call does to a file or a folder, rule by rule. The library and tclipper follow the same rules; the tool's options map to the properties named here (Commands).
- A path that is a folder means every file directly in it, in name order (ordinal), not its subfolders.
- Only files whose extension is
m4b,wav,mp3,mp4,flv,avi,mpgormov(any case) are clipped, unlessProcessEveryFileis set (-a). - The new length is the file's duration minus the trailer, minus the intro when
RemoveIntrois set. A file left with nothing (zero or less) is skipped with a console line. - The copy keeps the file's name and goes to a
clippedfolder beside the original, or toOutputDirectoryPath. An existing copy is overwritten. - ffmpeg re-encodes the copy, choosing codecs by the extension. Nothing else about the copy is chosen by TrailerClipper.
- The original stays unless
DeleteOriginalFilesis set (-d), and is deleted only after its copy was written. - A file ffmpeg cannot read or write does not stop the others; the failures are thrown together at the end (Errors and edge cases).
The examples use a folder Episodes with 10-second files made by ffmpeg's test sources: ep1.mp4 (H.264 and AAC), ep2.mp3, ep3.wav, ep4.m4b (AAC), extra.mkv (H.264 and Vorbis) and notes.txt.
The folder call on Home clipped the four files with listed extensions and left extra.mkv and notes.txt alone. With ProcessEveryFile, every file in the folder is tried:
var clipper = new TrailerClipper();
clipper.RemoveTrailers(new TrailerClipperOptions("Mixed", 2000m) { ProcessEveryFile = true });Starting on file: Mixed\ep3.wav
Finished on trimming file, output: <cwd>\Mixed\clipped\ep3.wav
Starting on file: Mixed\extra.mkv
Finished on trimming file, output: <cwd>\Mixed\clipped\extra.mkv
Mixed/clipped/ep3.wav: 8.000 s; audio pcm_s16le
Mixed/clipped/extra.mkv: 8.003 s; video h264, audio vorbis
Mixed/ep3.wav: 10.000 s; audio pcm_s16le
Mixed/extra.mkv: 10.003 s; video h264, audio vorbis
The extension check applies to a single file too. Naming a .mkv file on its own clips nothing and prints nothing:
new TrailerClipper().RemoveTrailers("Episodes/extra.mkv", 2000m);Episodes afterwards has no clipped folder. Set ProcessEveryFile to clip it.
The duration comes from ffprobe and is rounded to hundredths of a second, as 1.1.0 read ffmpeg's Duration: line. ffmpeg is then asked to start at the intro length and write duration - trailer - intro. What ffmpeg writes can be a few milliseconds off for formats with fixed-size audio frames. From the runs on these pages (ffmpeg 9.0.1 on Windows; ffmpeg n9.0.2 on Linux gave the same numbers):
| Input (10 s) | Trailer 2000 | Intro 1500, trailer 2000 | Intro 1500 only |
|---|---|---|---|
ep1.mp4 (H.264, AAC) |
8.000 s | 6.500 s | 8.500 s |
ep2.mp3 |
8.000 s | 6.500 s | 8.500 s |
ep3.wav |
8.000 s | 6.500 s | 8.500 s |
ep4.m4b (AAC) |
8.011 s | 6.509 s | 8.500 s |
extra.mkv with -a (10.003 s) |
8.003 s |
MP3 copies are the requested length. 1.1.0's bundled 2015 ffmpeg left the encoder's padding in them (8.033 s for an 8 s cut), see Versions and upgrading.
A file whose intro and trailer add up to its length or more is skipped, and nothing is written for it:
var clipper = new TrailerClipper();
clipper.RemoveIntrosAndTrailers("Short", 1500m, 2000m);Starting on file: Short\ep3.wav
Finished on trimming file, output: <cwd>\Short\clipped\ep3.wav
Starting on file: Short\short.wav
Skipped file, nothing is left after the cut: Short\short.wav
Short/clipped/ep3.wav: 6.500 s; audio pcm_s16le
Short/ep3.wav: 10.000 s; audio pcm_s16le
Short/short.wav: 3.000 s; audio pcm_s16le
A trailer of 0 copies the whole file (re-encoded). Negative lengths throw before any file is touched (Errors and edge cases).
TrailerClipper passes ffmpeg only the start time, the length, the input and the output path. ffmpeg picks the container from the output's extension and its default codecs for that container, so the copy is re-encoded, not cut in place. In the runs above the codecs came out as they went in (H.264 and AAC for MP4 and M4B, MP3, 16-bit PCM for WAV, H.264 and Vorbis for MKV), because ffmpeg's defaults matched the inputs. Bit rates and quality are ffmpeg's defaults, not the input's. The ffmpeg you install decides all of this.
A file with no extension cannot be written back, because ffmpeg cannot tell which container to use (Errors and edge cases).
For a folder, the copies go to <folder>/clipped; for a single file, to a clipped folder beside it:
var clipper = new TrailerClipper();
clipper.RemoveTrailers("Episodes/ep2.mp3", 2000m);Starting on file: Episodes/ep2.mp3
Finished on trimming file, output: <cwd>\Episodes\clipped\ep2.mp3
The "Starting" line repeats the path as you passed it; the "Finished" line gives the full path of the copy. With OutputDirectoryPath, every copy goes to that one folder, created when missing. A relative OutputDirectoryPath is relative to the current folder, not to the input. Here with DeleteOriginalFiles too:
var clipper = new TrailerClipper();
clipper.RemoveTrailers(new TrailerClipperOptions("Episodes", 2000m)
{
OutputDirectoryPath = "Clipped",
DeleteOriginalFiles = true,
OutputToConsole = false
});Clipped/ep1.mp4: 8.000 s; video h264, audio aac
Clipped/ep2.mp3: 8.000 s; audio mp3
Clipped/ep3.wav: 8.000 s; audio pcm_s16le
Clipped/ep4.m4b: 8.011 s; audio aac
Episodes/extra.mkv: 10.003 s; video h264, audio vorbis
Episodes/notes.txt: 10 bytes, not media
Clipped was made in the current folder, beside Episodes, and the four originals are gone. The two files that were not clipped stay.
With OutputToConsole (the default), each clipped file prints Starting on file: <path> after ffprobe has read it, then Finished on trimming file, output: <copy> or Skipped file, nothing is left after the cut: <path>. They go to Console.Out, so they reach whatever the program set it to (Recipes). A file ffmpeg cannot read prints nothing; the failure is in the exception.
MultiTaskFiles (-m) clips the files of a folder with Parallel.ForEach:
var clipper = new TrailerClipper();
clipper.RemoveTrailers(new TrailerClipperOptions("Episodes", 2000m) { MultiTaskFiles = true, OutputToConsole = false });It left the same four 8-second copies as a plain run. Each ffmpeg is a process of its own, so this can run several at once; with progress lines on, their order is whatever order the files finish in. The property's own documentation still calls it experimental. Missing ffmpeg surfaces as ToolNotFoundException here too, not wrapped in an AggregateException.
- Read subfolders of a folder.
- Change the original file, unless asked to delete it.
- Touch the network: it runs only the
ffmpegandffprobeit finds (Configuration). The tool's--install-ffmpegruns your package manager, which does download. - Accept a file name that contains a double quote (Errors and edge cases).
This wiki describes TrailerClipper and TrailerClipper.Tool 2.0.0 and was last updated on 2026-09-30. Both packages are MIT licensed. Report problems in the issues. On NuGet: TrailerClipper and TrailerClipper.Tool.
Using it
- Getting started
- Commands
- Configuration
- How files are clipped
- Errors and edge cases
- API reference
- Recipes
- FAQ
The releases
Contributing
Elsewhere