How to Set FFmpeg sc_threshold to Zero

Setting the -sc_threshold parameter to zero in FFmpeg disables automatic scene change detection, which is essential for forcing consistent keyframe (I-frame) intervals during video encoding. This article provides a direct, step-by-step guide on how to apply this setting in your FFmpeg commands, explaining the exact syntax and the practical scenarios where disabling scene detection is necessary, such as for HTTP Live Streaming (HLS) and DASH packaging.

The Command Syntax

To set the scene change threshold to zero, add the -sc_threshold 0 option to your FFmpeg command. It is typically used in conjunction with the -g (GOP size) parameter to ensure keyframes are placed at exact, predictable intervals.

Here is a basic example of the command:

ffmpeg -i input.mp4 -g 60 -sc_threshold 0 output.mp4

How the Parameters Work Together

Why Set sc_threshold to Zero?

In standard video encoding, letting the encoder insert keyframes at scene cuts improves visual quality and compression efficiency. However, you must disable this feature by setting the threshold to zero in the following scenarios:

  1. Adaptive Bitrate Streaming (HLS/DASH): Multi-bitrate streaming requires video segments to be perfectly aligned at the frame level. If one rendition inserts a keyframe at a scene cut and another does not, the segment boundaries will mismatch, causing buffering or playback errors when a user switches qualities.
  2. Fixed Segment Lengths: If you need to split a video into precise 2-second or 5-second segments, keyframes must occur exactly at those boundaries. Disabling scene detection guarantees this predictability.