Skip to content

Instantly share code, notes, and snippets.

@neyhart
Forked from kpostekk/full_export.py
Created October 5, 2022 17:06
Show Gist options
  • Save neyhart/e62c39806354d3fc0fe95f8cd7fd5110 to your computer and use it in GitHub Desktop.
Save neyhart/e62c39806354d3fc0fe95f8cd7fd5110 to your computer and use it in GitHub Desktop.
Simple python ffmpeg conversion script. From flac to mp3, aac and opus
import os
aac_cmd = 'ffmpeg -i "{file_name}" -c:a aac -b:a 256k aac/{output_name}.aac'
opus_cmd = 'ffmpeg -i "{file_name}" -c:a libopus -b:a 96k ./opus/{output_name}.opus'
mp3_cmd = 'ffmpeg -i "{file_name}" -c:a mp3 -b:a 128k ./mp3/{output_name}.mp3'
for d in ('mp3', 'opus', 'aac'):
os.mkdir(d)
counter = 1
for f in [x for x in os.listdir() if os.path.isfile(x) if '.flac' in x]:
os.system(aac_cmd.format(file_name=f, output_name=counter.__str__()))
os.system(opus_cmd.format(file_name=f, output_name=counter.__str__()))
os.system(mp3_cmd.format(file_name=f, output_name=counter.__str__()))
counter += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment