Change FFmpeg Exposure by Timestamp
This guide explains how to dynamically modify video exposure over
time using FFmpeg's exposure filter. You will learn how to
trigger exposure changes across specific time intervals using timeline
expressions (enable) as well as how to schedule precise
value updates at exact timestamps using the sendcmd
filter.
The exposure filter adjusts video exposure values in EV
(Exposure Value) steps, accepting values from -3.0 to
3.0. Because the filter accepts timeline editing and
run-time commands, you can manipulate it according to video timestamps
using two primary methods.
Method 1: Using
the enable Timeline Expression
The timeline editing feature (enable) applies the
exposure adjustment only when a timestamp condition evaluates to true.
In timeline expressions, the variable t represents the
current presentation timestamp in seconds.
To apply a fixed exposure boost of 1.5 between second 3
and second 8:
ffmpeg -i input.mp4 -vf "exposure=exposure=1.5:enable='between(t,3,8)'" -c:a copy output.mp4To set multiple distinct exposure adjustments at different points in
the video, chain multiple exposure filters together:
ffmpeg -i input.mp4 -vf "exposure=exposure=-1.0:enable='between(t,2,5)',exposure=exposure=1.2:enable='between(t,10,15)'" -c:a copy output.mp4Method 2: Dynamic
Scheduling with sendcmd
The exposure filter supports runtime commands. Using the
sendcmd filter, you can reprogram the exposure
parameter at exact timestamps sequentially within a single filter
instance.
The command format is:
[timestamp] exposure exposure [value]
You can pass these instructions directly via the command line:
ffmpeg -i input.mp4 -vf "sendcmd=c='0.0 exposure exposure 0; 2.5 exposure exposure 1.0; 6.0 exposure exposure -1.5; 9.0 exposure exposure 0',exposure" -c:a copy output.mp4Alternatively, you can write complex schedules to a text file named
commands.txt:
0.0 exposure exposure 0.0;
2.0 exposure exposure 0.5;
4.0 exposure exposure 1.0;
6.0 exposure exposure 1.5;
8.0 exposure exposure 0.0;
Apply the command file to your input:
ffmpeg -i input.mp4 -vf "sendcmd=f=commands.txt,exposure" -c:a copy output.mp4Modifying the Black Level Parameter
The exposure filter also includes a black
level correction parameter ranging from -1.0 to
1.0. You can alter the black level alongside the exposure
value using the same timestamp-driven approaches:
ffmpeg -i input.mp4 -vf "sendcmd=c='3.0 exposure black 0.1; 6.0 exposure black -0.05',exposure" -c:a copy output.mp4