Skip to content

Instantly share code, notes, and snippets.

@r1cc4rd0m4zz4
Created November 13, 2024 19:35
Show Gist options
  • Select an option

  • Save r1cc4rd0m4zz4/698a8f3cd9c8429a8dce99ed63888cf2 to your computer and use it in GitHub Desktop.

Select an option

Save r1cc4rd0m4zz4/698a8f3cd9c8429a8dce99ed63888cf2 to your computer and use it in GitHub Desktop.
Script to remove metadata from audio/video files using ffmpeg
#!/bin/bash
# Script to remove metadata from audio/video files using ffmpeg
# Usage: ./remove_metadata.sh input_file
# Example: ./remove_metadata.sh music.m4a
# Check if input file is provided
if [ $# -ne 1 ]; then
echo "Error: Please provide an input file"
echo "Usage: $0 input_file"
exit 1
fi
input_file="$1"
# Check if input file exists
if [ ! -f "$input_file" ]; then
echo "Error: Input file '$input_file' not found"
exit 1
fi
# Get file extension
extension="${input_file##*.}"
# Create output filename by adding '_nometa' before the extension
filename="${input_file%.*}"
output_file="${filename}_nometa.${extension}"
# Display the current metadata before removal
echo "Current metadata of the file:"
ffmpeg -i "$input_file" -f ffmetadata - 2>/dev/null
# Remove metadata while keeping the original codec
echo -e "\nRemoving metadata..."
ffmpeg -i "$input_file" -map_metadata -1 -c copy "$output_file" -v warning
# Verify that metadata was removed
echo -e "\nVerifying metadata removal for output file:"
ffmpeg -i "$output_file" -f ffmetadata - 2>/dev/null
echo -e "\nMetadata removal complete!"
echo "Output file saved as: $output_file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment