Skip to content

Instantly share code, notes, and snippets.

@lobotony
Created February 14, 2015 18:25
Show Gist options
  • Save lobotony/0cb8453d2cdc6ce9633e to your computer and use it in GitHub Desktop.
Save lobotony/0cb8453d2cdc6ce9633e to your computer and use it in GitHub Desktop.
Scrub metadata from m4a files by copying the AAC stream to a new file without reencoding, using ffmpeg. This script replaces the file you're scrubbing, so duplicate your data beforehand. I'm no shell expert and wanted something quick, so it's not very polished, e.g. it won't work with wildcards.
#!/bin/sh
INFILE="$@"
TEMPFILE=/tmp/$RANDOM
echo "processing file: " $INFILE
echo "extracting aac"
ffmpeg -i "$INFILE" -codec: copy $TEMPFILE.aac
echo "stuffing aac into m4a container"
ffmpeg -i $TEMPFILE.aac -bsf:a aac_adtstoasc -codec: copy $TEMPFILE.m4a
echo "replacing old with new"
rm "$INFILE"
mv $TEMPFILE.m4a "$INFILE"
@knightsamar
Copy link

Very useful! Thank you for making this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment