Script you can save as video-gui-deface.sh in your user folder and you can use it to cover faces of protesters in mp4 video files….
After saving script from below, make it executable: sudo chmod +x video-gui-deface.sh
Add alias in terminal conf file to execute command with one word, copy paste this line in your .zshrc or .bashrc file: alias videodeface=’/home/kali/video-gui-deface.sh’
Refresh bashrc or zshrc: source /home/kali/.zshrc
To use this script you should install necessary tools:
sudo apt-get install zenity mediainfo ffmpeg (plus deface: python3 -m pip install ‘git+https://github.com/ORB-HD/deface’)
Check smiley and other paths if it is not the same like in my case: SMILEY=”/home/kali/Pictures/angry.jpg”
Result example with moving face i.e. running that’s harder job for deface:
#!/bin/bash
# Zenity GUI MP4 face protection script using deface
# Requirements: deface, zenity, mediainfo, ffmpeg, cpulimit70 (alias), angry.jpg
# Define cpulimit70 function (70% CPU cap)
cpulimit70() {
cpulimit -l 70 -- "$@"
}
# === Step 0: Check dependencies ===
for cmd in zenity deface mediainfo ffmpeg cpulimit; do
if ! command -v $cmd &>/dev/null; then
zenity --error --text="$cmd is not installed or not in PATH. Aborting."
exit 1
fi
done
# Note: deface refuse shorter commands, it prefers full paths and not $HOME or similar
CPULIMIT="/usr/bin/cpulimit"
DEFACE="/usr/local/bin/deface"
SMILEY="/home/kali/Pictures/angry.jpg"
# === Step 1: Select video
INPUT=$(zenity --file-selection --title="Select MP4 video" --file-filter="*.mp4")
[[ -z "$INPUT" ]] && { zenity --error --text="No video selected."; exit 1; }
# === Step 2: Ask for compression (before deface) ===
zenity --question --title="Compress Video First?" \
--text="Do you want to compress the video BEFORE deface using H264 + MP3?"
if [[ $? -eq 0 ]]; then
compressed="${file%.mp4}-compressed.mp4"
zenity --info --text="Compressing to: $compressed"
sudo ffmpeg -i "$file" -vcodec libx264 -acodec mp3 "$compressed"
file="$compressed"
fi
# === Step 3: Ask face protection type ===
choice=$(zenity --list --radiolist --title="Face Protection" --text="Choose:" \
--column="Pick" --column="Option" TRUE "Blur" FALSE "Angry Overlay")
[[ -z "$choice" ]] && { zenity --error --text="No option selected."; exit 1; }
DIR=$(dirname "$INPUT")
BASE=$(basename "$INPUT" .mp4)
LOG="/tmp/deface_$(date +%s).log"
if [[ "$choice" == "Blur" ]]; then
OUTPUT="$DIR/${BASE}-blur.mp4"
METHOD="--replacewith blur --thresh 0.3 --keep-audio --scale 640x360 --draw-scores"
zenity --info --text="Applying blur with confidence overlay... This may take time."
elif [[ "$choice" == "Angry Overlay" ]]; then
OUTPUT="$DIR/${BASE}-angry.mp4"
if [[ ! -f "$SMILEY" ]]; then
zenity --error --text="Angry image not found at $SMILEY"; exit 1
fi
METHOD="--replacewith img --replaceimg \"$SMILEY\" --thresh 0.4 --keep-audio"
zenity --info --text="Overlaying angry emoji... Please wait."
fi
# Run deface with logging
eval "$CPULIMIT -l 70 -- $DEFACE \"$INPUT\" $METHOD -o \"$OUTPUT\"" 2>&1 | tee "$LOG"
if [[ -f "$OUTPUT" ]]; then
zenity --info --text="✅ Completed!\nSaved to:\n$OUTPUT"
else
zenity --error --text="❌ Failed!\nCheck log:\n$LOG"
fi
