Skip to content

Instantly share code, notes, and snippets.

@Qman11010101
Last active January 31, 2021 16:28
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 Qman11010101/c45eee4eaf041e1e7a2ce1edb8d9907e to your computer and use it in GitHub Desktop.
Save Qman11010101/c45eee4eaf041e1e7a2ce1edb8d9907e to your computer and use it in GitHub Desktop.
ffmpegを使ってwavをflacに変えるやつ
# Copyright 2021 Kjuman Enobikto
# Version: 3.8以上
# FFmpegのパスが通っている必要があります
# 配布: https://qmainconts.f5.si/index.html#wav2flac
import glob
import os
import subprocess
import sys
files = glob.glob("*.wav")
remove_origin = True
if len(arg := sys.argv) == 2:
if arg[1] in ["-s", "--save-origin"]:
remove_origin = False
print(files)
current_dir = os.getcwd()
for wavfile in files:
filename = wavfile.replace(".wav", "")
commandstr = f'ffmpeg -i "{current_dir}\\{filename}.wav" -vn -ar 44100 -ac 2 -acodec flac -f flac "{current_dir}\\{filename}.flac"'
subprocess.run(commandstr, shell=True)
if remove_origin:
os.remove(wavfile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment