Convert a video from dark mode to light mode with FFmpeg!
Let’s make it so you can record a demo (assuming you recorded it in VS Code) once in dark mode, and then convert that into light mode, in a single command!
Install FFmpeg
FFmpeg is the brains behind pretty much all video editing softwares. It’s a really awesome tool beyond just this use case!
You can go to their downloads page to clone the repo or go into details about how it runs, but here’s some shortcuts.
If you’ve already installed it, skip this section!
MacOS 🍏
If you’re on MacOS, you can use Homebrew to install FFmpeg:
brew install ffmpeg
Linux 🐧
If you’re on Linux:
sudo apt install ffmpeg
Windows 🪟
And if you’re on Windows:
-
Download the pre-built binaries. Choose the Windows version and click on the link to download a static build.
-
Extract the downloaded ZIP file to a folder of your choice, e.g.,
C:\ffmpeg
. I personally have ababyscripts
folder for small CLI apps like this or yt-dlp. -
Add the
bin
directory to your system’s PATH:- Open the Start Menu and search for “Environment Variables”, and click “Edit the system environment variables”.
- In the System Properties window, click the “Environment Variables” button.
- In the Environment Variables window, find the “Path” variable in the “System variables” section and select it. Click “Edit”.
- Click “New” and add the path to the
bin
directory of your FFmpeg installation, e.g.,C:\ffmpeg\bin
. - Click “OK” to close all windows.
-
Verify the installation by opening Command Prompt and typing
ffmpeg -version
.
Running the command
Now, whenever you have a dark mode video, let’s say it’s named input.mp4
, you can run this command in the folder where it’s located to get a light mode version named output.mp4
!
ffmpeg -i input.mp4 -vf "negate,hue=h=180,eq=contrast=1.2:saturation=1.1" output.mp4
🛑 You can stop here if you want to rest your brain 🛑
Creating a reusable alias
Now, this may be hard to remember, so what you can also do is create an alias for this in your terminal!
If you're on MacOS/Linux 🍏🐧
For MacOS/Linux, run the below command and then restart your terminal:
newCommand='
# Alias for converting videos from dark mode to light mode
convert-to-light-mode() {
inputFileName=$1
outputFileName=$2
if [ -z "$outputFileName" ]; then
fileBaseName="${inputFileName%.*}"
suffix="-light-mode"
fileExtension="${inputFileName##*.}"
outputFileName="${fileBaseName}${suffix}.${fileExtension}"
fi
ffmpeg -i "$inputFileName" -vf "negate,hue=h=180,eq=contrast=1.2:saturation=1.1" "$outputFileName"
}
'
# Add command to bash and zsh
echo $newCommand >> ~/.bashrc
echo $newCommand >> ~/.zshrc
(thanks to @chriswblake for help with this part!)
Now, when you want to run the command, you run:
convert-to-light-mode input.mp4 output.mp4
# or
convert-to-light-mode my-video.mp4
# the output here would be my-video-light-mode.mp4
If you're on Windows 🪟
And here’s the equivalent for Windows!
# A function for converting videos from dark mode to light mode
function Convert-ToLightMode {
param (
[string]$inputFileName,
[string]$outputFileName
)
if (-not $outputFileName) {
$fileBaseName = [System.IO.Path]::GetFileNameWithoutExtension($inputFileName)
$suffix = "-light-mode"
$fileExtension = [System.IO.Path]::GetExtension($inputFileName)
$outputFileName = "${fileBaseName}${suffix}${fileExtension}"
}
ffmpeg -i $inputFileName -vf "negate,hue=h=180,eq=contrast=1.2:saturation=1.1" $outputFileName
}
$profileContent = @"
function Convert-ToLightMode {
param (
[string]`$inputFileName,
[string]`$outputFileName
)
if (-not `$outputFileName) {
`$fileBaseName = [System.IO.Path]::GetFileNameWithoutExtension(`$inputFileName)
`$suffix = "-light-mode"
`$fileExtension = [System.IO.Path]::GetExtension(`$inputFileName)
`$outputFileName = "`$fileBaseName`$suffix`$fileExtension"
}
ffmpeg -i `$inputFileName -vf "negate,hue=h=180,eq=contrast=1.2:saturation=1.1" `$outputFileName
}
"@
Add-Content -Path $PROFILE -Value $profileContent
To use this, you would run it like so:
Convert-ToLightMode -inputFileName "input.mp4" -outputFileName "output.mp4"
# or
Convert-ToLightMode -inputFileName "my-video.mp4"
# the output here would be my-video-light-mode.mp4
After creating the alias, an added bonus 👀
Something that you can ALSO do with this script is export the light mode version as a .gif
image!
MacOS/Linux:
convert-to-light-mode input.mp4 output.gif
Windows:
Convert-ToLightMode -inputFileName "input.mp4" -outputFileName "output.gif"
Wow!
By the way, if you want your original video to be a .gif
too, you can run it fairly plainly with FFmpeg:
ffmpeg -i input.mp4 output.gif
Happy converting!
Let me know if you have any questions!
So far, this script seems to work best with the theme Dark Modern
. If you try other themes, let me know and I can add them here!