Skip to content

FFmpeg Short Clips

Axwabo edited this page Apr 1, 2026 · 2 revisions

Adding Short Clips With FFmpeg

You can add clips to the ShortClipCache with FFmpeg

Caution

If you pass a very long input (e.g. live stream), the server will hang, and most likely crash because it runs out of memory.

Important

Do not use short clips for long files. Stream them instead. Pass the maxDuration optional parameter to discard clips that are too long (e.g. longer than 30 seconds).

Example

C# 14 and later:

using SecretLabNAudio.Core.FileReading;
using SecretLabNAudio.FFmpeg;
using SecretLabNAudio.FFmpeg.Extensions;

// the file name without the extension will be the clip's name
ShortClipCache.AddFileWithFFmpeg("/path/to/clip.wav");
ShortClipCache.AddFileWithFFmpeg("/path/to/clip2.m4a");

// custom clip name
ShortClipCache.AddFileWithFFmpeg("/path/to/clip3.wav", "CustomName");

// any source
ShortClipCache.AddWithFFmpeg(
    new FFmpegArguments().WithInput("https://download.samplelib.com/mp3/sample-15s.mp3"),
    "15s-sample"
);

C# 13 and earlier:

using SecretLabNAudio.FFmpeg;
using SecretLabNAudio.FFmpeg.Extensions;

// the file name without the extension will be the clip's name
ShortClipCacheExtensions.AddFileWithFFmpeg("/path/to/clip.wav");
ShortClipCacheExtensions.AddFileWithFFmpeg("/path/to/clip2.m4a");

// custom clip name
ShortClipCacheExtensions.AddFileWithFFmpeg("/path/to/clip3.wav", "CustomName");

// any source
ShortClipCacheExtensions.AddWithFFmpeg(
    new FFmpegArguments().WithInput("https://download.samplelib.com/mp3/sample-15s.mp3"),
    "15s-sample"
);

Use the AddFileWithFFmpeg extension method to add a file. This method will not start FFmpeg if the file does not exist.

Call the AddWithFFmpeg method to pass a custom input (e.g. URL), which lets you customize the input or output options (e.g. section of the stream, filters).

Note

Adding clips with FFmpeg takes more time since a new process has to be started per clip.

Tip

See also: FFmpegArguments

If FFmpeg encountered an error while reading a short clip, the error can be found in the LocalAdmin logs:

  • Linux: ~/.config/SCP Secret Laboratory/LocalAdminLogs/<port>/<file>
  • Windows: %appdata%\SCP Secret Laboratory\LocalAdminLogs\<port>\<file>

Getting Started

Playing Audio

Advanced

Audio Processors

FFmpeg

v1 Guides

Caution

v1 will be out of support soon.

Clone this wiki locally