Skip to content

Instantly share code, notes, and snippets.

@YKamataki
Created June 28, 2024 05:10
Show Gist options
  • Save YKamataki/a5c519e6c3d58e7baba257bd3a678a5a to your computer and use it in GitHub Desktop.
Save YKamataki/a5c519e6c3d58e7baba257bd3a678a5a to your computer and use it in GitHub Desktop.
AAC mix w/ ffmpeg
#!/usr/bin/python3
"""
カレントディレクトリ内のAACファイルをミックスします。
シングルトラックで録音されたデータをまとめる用です。
全てのトラックが同じ長さであることが前提です。
ffmpegは、ご自身でイストールしてください。
"""
import os
import glob
import datetime
# AACファイルの一覧を取得
files = glob.glob("./*.aac")
# コマンドを作成
cmd = "ffmpeg"
for path in files:
cmd += f" -i {path}"
cmd += f" -filter_complex \"amix=inputs={len(files)}:duration=longest\""
filename = datetime.date.today().strftime("%Y-%M-%d") + ".aac"
cmd += f" {filename}"
print("COMMAND:\n",cmd)
input("ENTERで続行、^Cでキャンセル")
os.system(cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment