Last active
January 31, 2021 16:28
-
-
Save Qman11010101/c45eee4eaf041e1e7a2ce1edb8d9907e to your computer and use it in GitHub Desktop.
ffmpegを使ってwavをflacに変えるやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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