Skip to content

Instantly share code, notes, and snippets.

@hexpunk
Last active December 10, 2021 05:03
Show Gist options
  • Save hexpunk/33c5832099873be2c2d48cef39ecab49 to your computer and use it in GitHub Desktop.
Save hexpunk/33c5832099873be2c2d48cef39ecab49 to your computer and use it in GitHub Desktop.
Remove metadata from videos using ffmpeg
#!/bin/sh
set -eu
for target in "$@"; do
original=$target.original
if mv "$target" "$original"; then
if ! ffmpeg -hide_banner \
-i "$original" \
-map_metadata -1 \
-map_chapters -1 \
-c:v copy \
-c:a copy \
-fflags +bitexact \
-flags:v +bitexact \
-flags:a +bitexact \
"$target"; then
mv "$original" "$target"
exit 1
fi
if ! rm "$original"; then
echo "Could not delete \"$original\""
exit 1
fi
else
echo "Could not move \"$target\" to \"$original\""
exit 1
fi
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment