Skip to content

Instantly share code, notes, and snippets.

@Melon-Bread
Last active November 24, 2018 01:10
Show Gist options
  • Save Melon-Bread/c0c5f143391a30b1f4b16bb9da343fd5 to your computer and use it in GitHub Desktop.
Save Melon-Bread/c0c5f143391a30b1f4b16bb9da343fd5 to your computer and use it in GitHub Desktop.
A simple python script to convert Nintendo Switch audio files (.lopus) to Vorbis audio files (.ogg)
#!/usr/bin/env python3
"""
Converts .lopus to .ogg via vgmstream & ffmpeg
"""
__author__ = "Melon Bread"
__version__ = "0.5.0"
__license__ = "MIT"
import argparse
import os
import subprocess
def main(args):
file = args.input[:-6]
try:
print("Converting .lpous to .wav via vgmstream-cli...")
subprocess.Popen(['vgmstream-cli', '-o',
'{}.wav'.format(file), args.input]).wait()
pass
except Exception as e:
print("ERROR: Please make sure 'vgmstream-cli' is in the PATH!")
raise
try:
print("Converting .wav to .ogg via ffmpeg...")
subprocess.Popen(['ffmpeg', '-i', '{}.wav'.format(file), '-acodec',
'libvorbis', '{}.ogg'.format(file)]).wait()
pass
except Exception as e:
print("ERROR: Please make sure 'ffmpeg' is in the PATH!")
raise
print("Removing .wav file...")
os.remove("{}.wav".format(file))
if __name__ == "__main__":
""" This is executed when run from the command line """
parser = argparse.ArgumentParser()
parser.add_argument('-i', '--input', metavar='STRING', required=True,
help='.lopus file your want to convert to .ogg')
args = parser.parse_args()
main(args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment