2023-11-03 21:21:46 +00:00
|
|
|
#!/usr/bin/python3
|
|
|
|
import os
|
|
|
|
from render_kdenlive import KDEnliveProject, _CACHE
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
def generate_sax_mix(root):
|
|
|
|
os.chdir(root)
|
|
|
|
|
|
|
|
|
|
|
|
root = os.path.abspath(".")
|
|
|
|
|
|
|
|
long_wav = "Soon_Kim_Long_Reverb_Only2.wav"
|
|
|
|
nois_wav = "Soon_Kim_Noise.wav"
|
|
|
|
reverb_wav = "Soon_Kim_Short_Reverb_Mix2.wav"
|
2023-11-08 08:19:07 +00:00
|
|
|
'''
|
|
|
|
i = item.models.Item.objects.get(data__title='Soon_Kim_Long_Reverb_Only2')
|
|
|
|
i.files.all()[0].data.path
|
|
|
|
'/srv/pandora/data/media/6b/44/16/3f2905e886/data.wav'
|
|
|
|
|
|
|
|
i = item.models.Item.objects.get(data__title='Soon_Kim_Short_Reverb_Mix2')
|
|
|
|
i.files.all()[0].data.path
|
|
|
|
'/srv/pandora/data/media/ee/e0/04/d4ab42c3de/data.wav'
|
|
|
|
|
|
|
|
i = item.models.Item.objects.get(data__title='Soon_Kim_Noise')
|
|
|
|
i.files.all()[0].data.path
|
|
|
|
'/srv/pandora/data/media/84/88/87/d2fb2e2dc2/data.wav'
|
|
|
|
'''
|
2023-11-03 21:21:46 +00:00
|
|
|
|
|
|
|
|
2024-01-12 10:50:17 +00:00
|
|
|
reverb = {
|
|
|
|
"src": reverb_wav,
|
|
|
|
"duration": 3600.0,
|
|
|
|
"filter": {
|
|
|
|
"volume": "0.5"
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2023-11-03 21:21:46 +00:00
|
|
|
long = {
|
|
|
|
"src": long_wav,
|
|
|
|
"duration": 3600.0,
|
|
|
|
"filter": {
|
2023-11-07 23:04:37 +00:00
|
|
|
"volume": "-4"
|
2023-11-03 21:21:46 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
noise = {
|
|
|
|
"src": nois_wav,
|
|
|
|
"duration": 3600.0,
|
|
|
|
"filter": {
|
2024-01-12 10:50:17 +00:00
|
|
|
"volume": "4.75"
|
2023-11-03 21:21:46 +00:00
|
|
|
},
|
2023-11-14 10:12:18 +00:00
|
|
|
}
|
|
|
|
|
2024-01-12 10:50:17 +00:00
|
|
|
project = KDEnliveProject(root)
|
2023-11-03 21:21:46 +00:00
|
|
|
project.append_clip('A1', long)
|
|
|
|
project.append_clip('A2', noise)
|
|
|
|
path = os.path.join(root, "sax-mix.kdenlive")
|
|
|
|
with open(path, 'w') as fd:
|
|
|
|
fd.write(project.to_xml())
|
|
|
|
|
2024-01-12 10:50:17 +00:00
|
|
|
project = KDEnliveProject(root)
|
|
|
|
project.append_clip('A1', reverb)
|
|
|
|
path = os.path.join(root, "sax-reverb-mix.kdenlive")
|
|
|
|
with open(path, 'w') as fd:
|
|
|
|
fd.write(project.to_xml())
|
|
|
|
|
2023-11-03 21:21:46 +00:00
|
|
|
cmds = []
|
|
|
|
cmds.append([
|
|
|
|
"melt", "sax-mix.kdenlive", '-quiet', '-consumer', 'avformat:sax-mix.wav'
|
|
|
|
])
|
2024-01-12 10:50:17 +00:00
|
|
|
cmds.append([
|
|
|
|
"melt", "sax-reverb-mix.kdenlive", '-quiet', '-consumer', 'avformat:sax-reverb-mix.wav'
|
|
|
|
])
|
2023-11-03 21:21:46 +00:00
|
|
|
cmds.append([
|
|
|
|
"ffmpeg", "-y",
|
|
|
|
"-nostats", "-loglevel", "error",
|
|
|
|
"-f", "lavfi", "-i", "anullsrc=r=48000:cl=mono", "-t", "3600", "silence.wav"
|
|
|
|
])
|
|
|
|
|
|
|
|
for src, out1, out2 in (
|
2024-01-12 10:50:17 +00:00
|
|
|
('sax-reverb-mix.wav', "fl.wav", "fr.wav"),
|
2023-11-03 21:21:46 +00:00
|
|
|
("sax-mix.wav", "bl.wav", "br.wav"),
|
|
|
|
):
|
|
|
|
cmds.append([
|
|
|
|
"ffmpeg", "-y",
|
|
|
|
"-nostats", "-loglevel", "error",
|
|
|
|
"-i", src,
|
|
|
|
"-filter_complex",
|
|
|
|
"[0:0]pan=1|c0=c0[left]; [0:0]pan=1|c0=c1[right]",
|
|
|
|
"-map", "[left]", out1,
|
|
|
|
"-map", "[right]", out2,
|
|
|
|
])
|
|
|
|
|
|
|
|
cmds.append([
|
|
|
|
"ffmpeg", "-y",
|
|
|
|
"-nostats", "-loglevel", "error",
|
|
|
|
"-i", "fl.wav",
|
|
|
|
"-i", "fr.wav",
|
|
|
|
"-i", "silence.wav",
|
|
|
|
"-i", "silence.wav",
|
|
|
|
"-i", "bl.wav",
|
|
|
|
"-i", "br.wav",
|
|
|
|
"-filter_complex", "[0:a][1:a][2:a][3:a][4:a][5:a]amerge=inputs=6[a]",
|
|
|
|
"-map", "[a]",
|
|
|
|
"-ar", "48000",
|
|
|
|
"-c:a", "aac", "Saxophone-5.1.mp4"
|
|
|
|
])
|
|
|
|
for cmd in cmds:
|
|
|
|
print(" ".join([str(x) for x in cmd]))
|
|
|
|
subprocess.call(cmd)
|