Skip to content

Instantly share code, notes, and snippets.

@lordsutch
Created February 28, 2019 17:20
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 lordsutch/9882b84543bfbf8b7e8033c029451366 to your computer and use it in GitHub Desktop.
Save lordsutch/9882b84543bfbf8b7e8033c029451366 to your computer and use it in GitHub Desktop.
Script to encode the Anthem digital soundtrack to AAC for iTunes etc. Can be readily adapted to other WAV albums.
#!/usr/bin/env python3
# Get 'fdkaac' from https://github.com/nu774/fdkaac (or Homebrew etc.)
import glob
import subprocess
import sys
import os
def convert_file(filename, trackcount):
base, ext = os.path.splitext(filename)
outfile = f'{base}.m4a'
track, title = base.split('-', 1)
print(f'Converting track {track} ({title})', file=sys.stderr)
subprocess.run(['fdkaac', '-o', outfile,
'-m', '5', '--moov-before-mdat',
'--artist', 'Sarah Schachner',
'--album-artist', 'Sarah Schachner',
'--album', 'Anthem (Original Soundtrack)',
'--title', title,
'--genre', 'Soundtracks',
'--date', '2019',
'--composer', 'Sarah Schachner',
'--track', f'{track}/{trackcount}',
'--disk', '1/1',
filename])
subprocess.run(['mp4art', '--add', 'Anthem-AlbumArt-1000x1000.jpg', '-z',
outfile])
files = tuple(glob.glob('*.wav'))
trackcount = len(files)
for filename in files:
convert_file(filename, trackcount)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment