FFmpeg scdet Filter: How to Detect Scene Cuts

This article provides a practical guide on how to use the scdet (scene detection) filter in FFmpeg to automatically detect scene changes and cuts in a video. You will learn the essential command syntax, how to adjust detection thresholds for better accuracy, and how to export the scene cut metadata to a text file for further analysis or editing.

Understanding the scdet Filter

The scdet filter in FFmpeg detects scene transitions by comparing the intensity differences between consecutive video frames. When the difference passes a specified threshold, the filter flags a scene cut.

This filter is highly useful for automating video editing, generating chapter markers, or preparing video files for adaptive bitrate streaming.

Basic Command Syntax

The simplest way to run scene detection and view the results in your terminal is by routing the video through the scdet filter and outputting to a null format.

Run the following command in your terminal:

ffmpeg -i input.mp4 -vf scdet -f null -

As the command runs, FFmpeg will print console logs. Look for lines containing lavfi.scdet.score and lavfi.scdet.scene_change. When a scene change is detected, lavfi.scdet.scene_change will output a value of 1.

Adjusting Detection Parameters

The scdet filter accepts parameters to fine-tune its sensitivity. The two primary parameters are:

Example: Adjusting Sensitivity

To increase sensitivity (to catch quick cuts or low-contrast transitions), lower the threshold to 8:

ffmpeg -i input.mp4 -vf "scdet=threshold=8" -f null -

To decrease sensitivity (to avoid false positives from camera movement or flashlights), raise the threshold to 15:

ffmpeg -i input.mp4 -vf "scdet=threshold=15" -f null -

Exporting Scene Cuts to a Text File

Reading console outputs manually is impractical for long videos. You can pair the scdet filter with the metadata filter to log every detected scene cut, along with its exact timestamp, directly into a text file.

Use the following command to export the scene cut data:

ffmpeg -i input.mp4 -vf "scdet=t=10,metadata=print:key=lavfi.scdet.scene_change:file=scenecuts.txt" -f null -

Understanding the Exported File

The resulting scenecuts.txt file will contain entries looking like this:

frame:124  pts:4137    pts_time:4.137
lavfi.scdet.scene_change=1
frame:450  pts:15015   pts_time:15.015
lavfi.scdet.scene_change=1