Repository navigation
API Reference
Every public type and member of TrailerClipper 2.0.0, in the namespace TrailerClipperLib (assembly TrailerClipperLib.dll). "Since" is 1.1.0 for everything that was public in the published 1.1.0 (checked by reflection in the repository's PublicApi-1.1.0.txt) and 2.0.0 for what is new; versions before 1.1.0 were not checked. Every 1.1.0 member keeps its name, parameter names and parameter types, including the misspelled introLenghtInMilliseconds and trailerLenghtInMilliseconds, so calls with named arguments still compile.
Lengths are decimal milliseconds. Exceptions are listed on Errors and edge cases.
public class TrailerClipper : ITrailerClipperService: the clipper. It holds no state between calls beyond the ffmpeg runner, and each call runs ffprobe and ffmpeg synchronously.
| Member | Since | What it does |
|---|---|---|
TrailerClipper() |
1.1.0 | a clipper that runs the ffmpeg FFmpegLocator finds |
void RemoveTrailers(string directoryPath, decimal milliseconds) |
1.1.0 | cuts milliseconds off the end of a file, or of each media file in a folder |
void RemoveIntros(string path, decimal introLenghtInMilliseconds) |
1.1.0 | cuts the start; on a single file since 2.0.0 (1.1.0 threw) |
void RemoveIntrosAndTrailers(string path, decimal introLenghtInMilliseconds, decimal trailerLenghtInMilliseconds) |
1.1.0 | cuts both; on a single file since 2.0.0 (1.1.0 threw) |
void RemoveTrailers(TrailerClipperOptions options) |
1.1.0 | clips as the options say |
void RemoveTrailers(IEnumerable<TrailerClipperOptions> options, string? configFileOutputPath = null) |
1.1.0 | clips each entry in order, then writes them to the file when the path is not null or blank |
void RemoveTrailers(IEnumerable<TrailerClipperOptions> options, bool saveOptionsToFile = false) |
1.1.0 | the same, writing TrailerClipperConfig.json in the current folder when true |
void RemoveTrailersWithOptionsFile(string? pathToOptionsFile = null) |
1.1.0 | clips as a settings file says; with null, TrailerClipperConfig.json in the current folder, or a console line when it is missing |
void CreateDefaultSampleConfig() |
1.1.0 | writes the sample TrailerClipperConfig.json, unless it exists (Configuration) |
The two list overloads both have an optional second parameter, so a call with only the list does not compile; pass the second argument (FAQ). Settings are written only after every entry was clipped without an exception.
public interface ITrailerClipperService, since 1.1.0: the seven clipping methods above (not CreateDefaultSampleConfig). Its RemoveTrailers(string path, decimal trailerLenghtInMilliseconds) names its parameters differently from the class's RemoveTrailers(string directoryPath, decimal milliseconds); named arguments must use the names of the type you call through.
public class TrailerClipperOptions, since 1.1.0: what to clip and how. The property order is the order in the settings file.
| Member | Since | Default | Meaning |
|---|---|---|---|
TrailerClipperOptions() |
1.1.0 |
OutputToConsole true, everything else default |
|
TrailerClipperOptions(string? path) |
1.1.0 | sets InputPath
|
|
TrailerClipperOptions(string? path, decimal milliseconds) |
1.1.0 | sets InputPath and TrailerLengthInMilliSeconds
|
|
bool OutputToConsole |
1.1.0 | true | print the progress lines |
bool MultiTaskFiles |
1.1.0 | false | clip a folder's files in parallel |
string? OutputDirectoryPath |
1.1.0 | null | one folder for every copy (relative to the current folder); null means clipped beside each file |
bool ProcessEveryFile |
1.1.0 | false | ignore the extension list |
bool RemoveIntro |
1.1.0 | false | also cut IntroLengthInMilliseconds off the start |
bool DeleteOriginalFiles |
1.1.0 | false | delete each original after its copy is written |
decimal IntroLengthInMilliseconds |
1.1.0 | 0 | |
string? InputPath |
1.1.0 | null | a file or a folder |
decimal TrailerLengthInMilliSeconds |
1.1.0 | 0 | note the capital S |
bool OutputClippingConfigToFile |
1.1.0 | false | never read |
string? ClippingConfigOutputFilePath |
1.1.0 | null | never read |
bool IsInputPathADirectory { get; } |
1.1.0 | true when InputPath names an existing folder |
|
string? FFmpegDirectory |
2.0.0 | null | the folder holding ffmpeg and ffprobe; never written to settings files (Configuration) |
var options = new TrailerClipperOptions("Episodes", 2000m);
Console.WriteLine($"{options.InputPath} {options.TrailerLengthInMilliSeconds} {options.OutputToConsole} {options.IsInputPathADirectory}");Episodes 2000 True True
public static class FFmpegLocator, since 2.0.0: finds ffmpeg. It only looks at the file system.
| Member | What it does |
|---|---|
const string EnvironmentVariable |
"TRAILERCLIPPER_FFMPEG" |
static string InstallHint { get; } |
the install advice used in ToolNotFoundException and by tclipper
|
static string? Find(string? preferredDirectory = null) |
the full path of the first folder holding both programs, or null; a given folder is the only one checked |
static IEnumerable<string> CandidateDirectories() |
the folders Find() searches, in order, whether or not they exist |
Console.WriteLine(FFmpegLocator.InstallHint);ffmpeg and ffprobe were not found. Install ffmpeg (Windows: winget install --id Gyan.FFmpeg -e; macOS: brew install ffmpeg; Linux: sudo apt install ffmpeg or sudo dnf install ffmpeg), or run 'tclipper --install-ffmpeg', or point TrailerClipperOptions.FFmpegDirectory or the TRAILERCLIPPER_FFMPEG environment variable at the folder that holds them.
The text is the same on every operating system. Examples of Find and CandidateDirectories are on Configuration.
public sealed class ToolNotFoundException : InvalidOperationException, since 2.0.0, marked [Serializable]: ffmpeg or ffprobe was not found. Constructors: () (message InstallHint), (string message), (string message, Exception innerException). Because it derives from InvalidOperationException, a catch (InvalidOperationException) written for 1.x catches it too.
public class ClipperCommandLineInterpreter : ICommandLineInterpreter, since 1.1.0: turns tclipper's arguments into options. ICommandLineInterpreter declares only ParseCommandLineArgs.
| Member | What it returns |
|---|---|
TrailerClipperOptions? ParseCommandLineArgs(string[]? args) |
the options, or null after printing why (also null for -z alone, silently) |
string? ReadConfigFilePath(string[]? args) |
the argument after a leading -c or -config, else null; throws IndexOutOfRangeException for -c alone |
bool ShouldDumpConfigFile(string[] args) |
whether -o is present |
string? ReadConfigOutputPath(string[] args) |
the argument after -o, or null |
bool ShouldDisplayHelp(string[] args) |
whether -h or -help is present |
bool ShouldCreateDefaultSampleConfig(string[] args) |
whether -z is present |
var interpreter = new ClipperCommandLineInterpreter();
var options = interpreter.ParseCommandLineArgs(new[] { "-i", "1500", "-cf", "Episodes", "2000" });
Console.WriteLine($"{options.InputPath}: intro {options.RemoveIntro} {options.IntroLengthInMilliseconds}, trailer {options.TrailerLengthInMilliSeconds}, console {options.OutputToConsole}");
Console.WriteLine(interpreter.ReadConfigFilePath(new[] { "-c", "saved.json" }));
Console.WriteLine(interpreter.ShouldDumpConfigFile(new[] { "Episodes", "2000", "-o", "saved.json" }));
Console.WriteLine(interpreter.ParseCommandLineArgs(new[] { "Episodes", "2000,5" }) == null);Episodes: intro True 1500, trailer 2000, console False
saved.json
True
Incorrect parameter, new duration in milliseconds: '2000,5' cannot be parsed
True
ParseCommandLineArgs checks that the path exists, relative to the current folder. ShouldDumpConfigFile, ReadConfigOutputPath, ShouldDisplayHelp and ShouldCreateDefaultSampleConfig throw ArgumentNullException for a null array, as 1.1.0 did.
public class TcHelpReader, since 1.1.0. string ReadHelpFileText() returns the help text tclipper -h prints (Commands), from a resource embedded in the assembly.
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