Skip to content

Instantly share code, notes, and snippets.

@Forceflow
Created October 10, 2019 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Forceflow/e5e31515337b197ee25e66c466dcbe8f to your computer and use it in GitHub Desktop.
Save Forceflow/e5e31515337b197ee25e66c466dcbe8f to your computer and use it in GitHub Desktop.
Strip all metadata from video file using ffmpeg
#!/bin/bash
#Usage: ./stripmetadata.sh filename.mp4 (or whatever video format ffmpeg takes)
# Fancy colors
RED='\033[1;31m'
GREEN='\033[1;32m'
NC='\033[0m'
# Grab variables
filename="$1"
ffmpeg_version="$(ffmpeg -version | head -n 1)"
echo -e "${GREEN}INFO${NC}: Stripping metadata from ${filename} with ${ffmpeg_version}"
ffmpeg -hide_banner -loglevel warning -i "$filename" -map_metadata -1 -c:v copy -c:a copy "strip_${filename}" || { echo -e "${RED}ERR:${NC} ffmpeg reported an error - exiting" ; exit 1; }
echo -e "${GREEN}INFO${NC}: Removing original ${filename}"
rm "$filename" || { echo -e "${RED}ERR:${NC} Could not remove original file - exiting" ; exit 1; }
echo -e "${GREEN}INFO${NC}: Renaming strip_${filename} to ${filename}"
mv "strip_${filename}" "$filename" || { echo -e "${RED}ERR:${NC} Could not rename stripped version to original - exiting" ; exit 1; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment