Repository navigation
Configuration
TrailerClipper is configured in two places. A JSON settings file holds what to clip: -o and -z write it, and -c and tclipper with no arguments read it. The machine settings say where ffmpeg is: an option, an environment variable, PATH and a list of known folders. The ffmpeg folder is never stored in the settings file, because it belongs to the machine.
The file is a JSON array with one object per input path. Each object has the properties of TrailerClipperOptions (API reference), written in the class's declaration order, without indentation:
| Property | Meaning | Default when missing |
|---|---|---|
InputPath |
a file, or a folder whose media files are all clipped | none: required |
TrailerLengthInMilliSeconds |
how much to cut off the end | 0 |
RemoveIntro |
whether to cut the start too | false |
IntroLengthInMilliseconds |
how much to cut off the start, when RemoveIntro is true |
0 |
OutputDirectoryPath |
where the copies go; null means a clipped folder beside each file |
null |
DeleteOriginalFiles |
delete each original after its copy is written | false |
ProcessEveryFile |
try every file, whatever its extension | false |
MultiTaskFiles |
clip the files of a folder in parallel | false |
OutputToConsole |
print the progress lines | true |
OutputClippingConfigToFile, ClippingConfigOutputFilePath
|
written for 1.x compatibility, never read | false, null |
IsInputPathADirectory |
written (whether InputPath was a folder when saved), ignored when read |
Note the capital S in TrailerLengthInMilliSeconds and the small s in IntroLengthInMilliseconds; both are 1.1.0's names. When reading, the case of property names does not matter.
The library writes the file after clipping when you pass a path, and the tool does the same for -o <file>:
var clipper = new TrailerClipper();
clipper.RemoveTrailers(new[]
{
new TrailerClipperOptions("Q&A", 2000m) { OutputToConsole = false, FFmpegDirectory = FFmpegLocator.Find() }
}, "saved.json");
Console.WriteLine(File.ReadAllText("saved.json"));prints:
[{"OutputToConsole":false,"MultiTaskFiles":false,"OutputDirectoryPath":null,"ProcessEveryFile":false,"RemoveIntro":false,"DeleteOriginalFiles":false,"IntroLengthInMilliseconds":0,"InputPath":"Q\u0026A","TrailerLengthInMilliSeconds":2000,"OutputClippingConfigToFile":false,"ClippingConfigOutputFilePath":null,"IsInputPathADirectory":true}]
Three things to see there. FFmpegDirectory was set and is not in the file. & is written as the six characters \u0026; <, > and ' are escaped the same way (\u003c, \u003e, \u0027), as 1.1.0's JavaScriptSerializer wrote them; every other character, accented letters included, is written as itself. And the file has no line breaks.
tclipper -z, or CreateDefaultSampleConfig() from code, writes TrailerClipperConfig.json in the current folder unless it exists:
new TrailerClipper().CreateDefaultSampleConfig();
Console.WriteLine(File.ReadAllText("TrailerClipperConfig.json"));[{"OutputToConsole":true,"MultiTaskFiles":false,"OutputDirectoryPath":"Clipped","ProcessEveryFile":false,"RemoveIntro":true,"DeleteOriginalFiles":false,"IntroLengthInMilliseconds":3500,"InputPath":"Original","TrailerLengthInMilliSeconds":17500,"OutputClippingConfigToFile":false,"ClippingConfigOutputFilePath":null,"IsInputPathADirectory":false}]
The sample clips a folder named Original (3.5 s intro, 17.5 s trailer) into a folder named Clipped. Change InputPath before using it: tclipper with no arguments reads this file from the current folder and fails while Original does not exist (Commands). A relative OutputDirectoryPath is relative to the current folder, not to the input (How files are clipped).
tclipper -c <file>, or RemoveTrailersWithOptionsFile(path) from code, reads the file and clips each entry in order. The reader is lenient in the ways 1.1.0's was: property names in any case, numbers and booleans written as strings, and trailing commas. This hand-written file clips quietly:
File.WriteAllText("mine.json", """
[
{ "inputpath": "Episodes", "trailerLengthInMilliSeconds": "2000", "outputtoconsole": "false", },
]
""");
new TrailerClipper().RemoveTrailersWithOptionsFile("mine.json");It printed nothing and left four 8-second copies in Episodes/clipped. Single-quoted strings, unquoted property names, an empty file and a file holding only null are refused; the messages are on Errors and edge cases.
With no path, RemoveTrailersWithOptionsFile() reads TrailerClipperConfig.json from the current folder, and prints No parameters and no config file available, use -h for help when there is none.
TrailerClipper needs a folder that holds both ffmpeg and ffprobe (with or without .exe). It takes the first of:
-
TrailerClipperOptions.FFmpegDirectory, when set. Only that folder is checked: if it lacks either program, clipping throwsToolNotFoundExceptionand nothing else is searched. - The folder named by the
TRAILERCLIPPER_FFMPEGenvironment variable. - Each folder on
PATH, in order. Relative entries such as.are skipped, so anffmpegin the current folder is never run by accident. - Known install folders, so that a terminal opened before an install still finds ffmpeg. On Windows: winget's
Linksfolder, thebinfolder of eachGyan.FFmpeg*andBtbN.FFmpeg*package under winget'sPackagesfolder (newest build name first), Chocolatey'sbinand Scoop'sshims. Elsewhere:/opt/homebrew/bin,/usr/local/bin,/usr/binand/snap/bin.
Only the file names are checked, not what the files are. FFmpegLocator.CandidateDirectories() lists steps 2 to 4. On Windows, with PATH set to C:\Windows\system32;C:\Windows:
Environment.SetEnvironmentVariable("TRAILERCLIPPER_FFMPEG", @"D:\tools\ffmpeg\bin");
foreach (var folder in FFmpegLocator.CandidateDirectories())
Console.WriteLine(folder);D:\tools\ffmpeg\bin
C:\Windows\system32
C:\Windows
<home>\AppData\Local\Microsoft\WinGet\Links
<home>\AppData\Local\Microsoft\WinGet\Packages\Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe\ffmpeg-9.0.1-full_build\bin
C:\ProgramData\chocolatey\bin
<home>\scoop\shims
The winget package folder is listed only when it exists (here, ffmpeg 9.0.1 from winget). The candidates are listed whether or not they exist; Find() returns the first that holds both programs, as a full path.
Two folders A and B, each holding (empty) files named ffmpeg.exe and ffprobe.exe, with the variable naming B:
Directory.CreateDirectory("A");
Directory.CreateDirectory("B");
foreach (var name in new[] { "A/ffmpeg.exe", "A/ffprobe.exe", "B/ffmpeg.exe", "B/ffprobe.exe" })
File.WriteAllText(name, "");
Environment.SetEnvironmentVariable("TRAILERCLIPPER_FFMPEG", Path.GetFullPath("B"));
Console.WriteLine(FFmpegLocator.Find("A"));
Console.WriteLine(FFmpegLocator.Find());
Console.WriteLine(FFmpegLocator.Find("C") ?? "null");<cwd>\A
<cwd>\B
null
A folder you pass wins over the variable; the variable wins over PATH; and a folder you pass that lacks the programs gives null, not a search. FFmpegDirectory on the options is passed to Find in the same way. The same three lines came out on .NET 8 and .NET Framework 4.8.
tclipper has no option for the folder; use TRAILERCLIPPER_FFMPEG, PATH or a known folder. How each run on these pages found ffmpeg:
- Every Windows run: through PATH, in winget's
Gyan.FFmpegpackage folder (ffmpeg 9.0.1, gyan.dev full build). - A Windows run with that folder taken off PATH still clipped (
tclipper -cf Episodes 2000, exit code 0): it found the same folder as a known install folder. On a machine with ffmpeg from winget, removing it from PATH is not enough to hide it. - Linux runs: through PATH (ffmpeg n9.0.2 from BtbN's builds, in a user folder), except the runs below and on Commands that take it off PATH on purpose.
On Ubuntu with PATH set to /usr/bin:/bin (no ffmpeg there) and the variable naming the ffmpeg folder (<ffmpeg> here):
$ tclipper -cf Episodes 2000
$ echo $?
0It clipped the four files. With the same PATH and no variable, it finds nothing and says so (Commands).
| What | Set by | Wins over |
|---|---|---|
| what to clip | the command line, or the settings file named by -c, or TrailerClipperConfig.json when there are no arguments |
-c must be first and then the rest of the line is ignored; the default file is read only with no arguments at all |
| where ffmpeg is |
FFmpegDirectory (library only) |
the variable, PATH and known folders (never searched when it is set) |
TRAILERCLIPPER_FFMPEG |
PATH and known folders | |
| PATH | known folders |
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