From 7368316f8d4b9a4fbe8725cd8f5ad031db2b3d5b Mon Sep 17 00:00:00 2001 From: j Date: Fri, 3 Nov 2023 22:15:20 +0100 Subject: [PATCH] new mix --- render.py | 49 ++++++++++++++++++++++++++++++++++------------ render_kdenlive.py | 13 ++++++++++-- 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/render.py b/render.py index 87e9f48..c9c559f 100644 --- a/render.py +++ b/render.py @@ -56,13 +56,23 @@ def compose(clips, target=150, base=1024, voice_over=None): 'back': { 'V1': [], 'V2': [], + 'A1': [], }, - 'audio': { + 'audio-center': { + 'A1': [], + }, + 'audio-front': { 'A1': [], 'A2': [], 'A3': [], 'A4': [], - } + }, + 'audio-rear': { + 'A1': [], + 'A2': [], + 'A3': [], + 'A4': [], + }, } all_clips = clips.copy() seq = random(base) @@ -85,13 +95,20 @@ def compose(clips, target=150, base=1024, voice_over=None): target = vo_min elif vo_min < target: offset = (target - vo_min) / 2 - scene['audio']['A3'].append({ + scene['audio-center']['A1'].append({ + 'blank': True, + 'duration': offset + }) + scene['audio-rear']['A1'].append({ 'blank': True, 'duration': offset }) vo_min += offset for vo in voice_overs: - scene['audio']['A3'].append(vo) + scene['audio-center']['A1'].append(vo) + vo_low = vo.copy() + vo_low['filter'] = {'volume': '-6'} + scene['audio-rear']['A1'].append(vo_low) clip = None while target - length > 0 and clips: @@ -202,12 +219,16 @@ def compose(clips, target=150, base=1024, voice_over=None): blur = seq() * 3 if blur: scene['back']['V1'][-1]['filter']['blur'] = blur - scene['audio']['A1'].append({ + scene['back']['A1'].append({ 'duration': clip['duration'], 'src': clip['original'], }) # TBD: Foley - scene['audio']['A2'].append({ + scene['audio-front']['A2'].append({ + 'duration': clip['duration'], + 'src': foley, + }) + scene['audio-rear']['A2'].append({ 'duration': clip['duration'], 'src': foley, }) @@ -346,7 +367,9 @@ def render_all(options): if ext == '.wav': cmd += ['vn=1'] else: - cmd += ['an=1', 'vcodec=libx264', 'x264opts=keyint=1', 'crf=15'] + if not timeline.endswith("back.kdenlive"): + cmd += ['an=1'] + cmd += ['vcodec=libx264', 'x264opts=keyint=1', 'crf=15'] subprocess.call(cmd) if ext == '.wav' and timeline.endswith('audio.kdenlive'): cmd = [ @@ -362,9 +385,9 @@ def render_all(options): fragment_prefix = Path(fragment_prefix) cmds = [] for src, out1, out2 in ( - ("audio-A1.wav", "fl.wav", "fr.wav"), - ("audio-A2.wav", "fc.wav", "lfe.wav"), - ("audio-A3.wav", "bl.wav", "br.wav"), + ("audio-front.wav", "fl.wav", "fr.wav"), + ("audio-center.wav", "fc.wav", "lfe.wav"), + ("audio-rear.wav", "bl.wav", "br.wav"), ): cmds.append([ "ffmpeg", "-y", @@ -390,15 +413,15 @@ def render_all(options): cmds.append([ "ffmpeg", "-y", "-nostats", "-loglevel", "error", - "-i", fragment_prefix / "back.mp4", + "-i", fragment_prefix / "front.mp4", "-i", fragment_prefix / "audio-5.1.mp4", "-c", "copy", - fragment_prefix / "back-5.1.mp4", + fragment_prefix / "front-5.1.mp4", ]) for cmd in cmds: #print(" ".join([str(x) for x in cmd])) subprocess.call(cmd) - shutil.move(fragment_prefix / "back-5.1.mp4", fragment_prefix / "back.mp4") + shutil.move(fragment_prefix / "front-5.1.mp4", fragment_prefix / "front.mp4") for fn in ( "audio-5.1.mp4", "fl.wav", "fr.wav", "fc.wav", "lfe.wav", "bl.wav", "br.wav", ): diff --git a/render_kdenlive.py b/render_kdenlive.py index 6eb9067..92a5f15 100644 --- a/render_kdenlive.py +++ b/render_kdenlive.py @@ -500,7 +500,7 @@ class KDEnliveProject: ["0", "00:00:00.000=%s" % value], ["kdenlive:collapsed", "0"], ])] - if name == "blur": + elif name == "blur": return [self.get_element("filter", [ ["mlt_service", "avfilter.avgblur"], ["kdenlive_id", "avfilter.avgblur"], @@ -509,7 +509,7 @@ class KDEnliveProject: ["planes", "7"], ["kdenlive:collapsed", "0"], ])] - if name == "mask": + elif name == "mask": mask = [ self.get_element("filter", [ ["mlt_service", "frei0r.saturat0r"], @@ -532,6 +532,15 @@ class KDEnliveProject: ]) ] return mask + elif name == "volume": + return [self.get_element("filter", [ + ["window", "75"], + ["max_gain", "20db"], + ["mlt_service", "volume"], + ["kdenlive_id", "volume"], + ["level", "00:00:00.000=%s" % value], + ["kdenlive:collapsed", "0"], + ])] else: return [ self.get_element("filter", [