From e0b157de641b70889efaa1d534025f43cb020a52 Mon Sep 17 00:00:00 2001 From: j Date: Thu, 19 Oct 2023 13:10:23 +0100 Subject: [PATCH 1/5] only create 5.1 mix once --- render.py | 55 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/render.py b/render.py index 0fd5add..2a9d9a8 100644 --- a/render.py +++ b/render.py @@ -90,6 +90,10 @@ def compose(clips, target=150, base=1024, voice_over=None): length += clip['duration'] fg = clip['foreground'] + if 'foley' in clip: + foley = clip['foley'] + else: + foley = fg if 'foreground2' in clip: if chance(seq, 0.5): fg = clip['foreground2'] @@ -140,9 +144,10 @@ def compose(clips, target=150, base=1024, voice_over=None): 'duration': clip['duration'], 'src': clip['original'], }) + # TBD: Foley scene['audio']['A2'].append({ 'duration': clip['duration'], - 'src': fg, + 'src': foley, }) return scene @@ -286,33 +291,43 @@ 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-A1.wav", "fl.wav", "fr.wav"), + ("audio-A2.wav", "fc.wav", "lfe.wav"), + ("audio-A3.wav", "bl.wav", "br.wav"), ): cmds.append([ - 'ffmpeg', '-y', - '-nostats', '-loglevel', 'error', - '-i', fragment_prefix / src, - '-filter_complex', + "ffmpeg", "-y", + "-nostats", "-loglevel", "error", + "-i", fragment_prefix / src, + "-filter_complex", "[0:0]pan=1|c0=c0[left]; [0:0]pan=1|c0=c1[right]", "-map", "[left]", fragment_prefix / out1, "-map", "[right]", fragment_prefix / out2, ]) - cmds.append([ - 'ffmpeg', '-y', - '-nostats', '-loglevel', 'error', - '-i', fragment_prefix / "fl.wav", - '-i', fragment_prefix / "fr.wav", - '-i', fragment_prefix / "fc.wav", - '-i', fragment_prefix / "lfe.wav", - '-i', fragment_prefix / "bl.wav", - '-i', fragment_prefix / "br.wav", - '-filter_complex', "[0:a][1:a][2:a][3:a][4:a][5:a]amerge=inputs=6[a]", - "-map", "[a]", "-c:a", "aac", fragment_prefix / "audio-5.1.mp4" - ]) + cmds.append([ + "ffmpeg", "-y", + "-nostats", "-loglevel", "error", + "-i", fragment_prefix / "fl.wav", + "-i", fragment_prefix / "fr.wav", + "-i", fragment_prefix / "fc.wav", + "-i", fragment_prefix / "lfe.wav", + "-i", fragment_prefix / "bl.wav", + "-i", fragment_prefix / "br.wav", + "-filter_complex", "[0:a][1:a][2:a][3:a][4:a][5:a]amerge=inputs=6[a]", + "-map", "[a]", "-c:a", "aac", fragment_prefix / "audio-5.1.mp4" + ]) for cmd in cmds: + #print(" ".join([str(x) for x in cmd])) subprocess.call(cmd) + ''' + for fn in ( + "audio-A1.wav", "audio-A2.wav", "audio-A3.wav", + "fl.wav", "fr.wav", "fc.wav", "lfe.wav", "bl.wav", "br.wav", + ): + fn = fragment_prefix / fn + if os.path.exists(fn): + os.unlink(fn) + ''' print("Duration - Target: %s Actual: %s" % (target_position, position)) with open(_cache, "w") as fd: json.dump(_CACHE, fd) From 4491abc277d6643affdbcd75b189266409699e43 Mon Sep 17 00:00:00 2001 From: j Date: Thu, 19 Oct 2023 15:52:12 +0100 Subject: [PATCH 2/5] add editing tags --- config.jsonc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/config.jsonc b/config.jsonc index 4345d24..23e4036 100644 --- a/config.jsonc +++ b/config.jsonc @@ -547,6 +547,16 @@ examples (config.SITENAME.jsonc) that are part of this pan.do/ra distribution. "filter": true, "sort": true }, + { + "id": "editingtags", + "title": "Editing Tags", + "type": ["string"], + "autocomplete": true, + "columnRequired": true, + "columnWidth": 180, + "filter": true, + "sort": true + }, { "id": "tags", "title": "Tags", From 6071b71752268448bee8fe70d51587393c1f3886 Mon Sep 17 00:00:00 2001 From: j Date: Thu, 19 Oct 2023 15:52:35 +0100 Subject: [PATCH 3/5] load editing tags --- management/commands/generate_clips.py | 1 + 1 file changed, 1 insertion(+) diff --git a/management/commands/generate_clips.py b/management/commands/generate_clips.py index 477b1f0..b9e46f3 100644 --- a/management/commands/generate_clips.py +++ b/management/commands/generate_clips.py @@ -38,6 +38,7 @@ class Command(BaseCommand): durations.append(e.files.all()[0].duration) clip["duration"] = min(durations) clip['tags'] = i.data.get('tags', []) + clip['editingtags'] = i.data.get('editingtags', []) if "original" in clip and "foreground" in clip and "background" in clip: clips.append(clip) else: From 7fe4b02552a5c7435e7d689da2902750fc79b604 Mon Sep 17 00:00:00 2001 From: j Date: Thu, 19 Oct 2023 15:52:55 +0100 Subject: [PATCH 4/5] use batch for vo --- static/js/infoView.t_for_time.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/static/js/infoView.t_for_time.js b/static/js/infoView.t_for_time.js index 7a87c3d..1d1d684 100644 --- a/static/js/infoView.t_for_time.js +++ b/static/js/infoView.t_for_time.js @@ -567,7 +567,7 @@ pandora.ui.infoView = function(data, isMixed) { ], operator: '&' }, - keys: ['title', 'type', 'id'], + keys: ['title', 'type', 'id', 'batch'], range: [0, 10] }; $element.appendTo($text); @@ -575,6 +575,9 @@ pandora.ui.infoView = function(data, isMixed) { response.data.items.forEach(item => { if (item.id != data.id) { var type = item.type ? item.type[0] : 'Unknown' + if (type == 'Voice Over' && item.batch) { + type = item.batch + } $element.append( ` ${type}` ) From 73a9481ef19bc6aa36a78ad91ddc5b952ba68e67 Mon Sep 17 00:00:00 2001 From: j Date: Thu, 19 Oct 2023 15:53:18 +0100 Subject: [PATCH 5/5] fix off by one and make option to load melt outside of class --- render_kdenlive.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/render_kdenlive.py b/render_kdenlive.py index 53c6b07..726550c 100644 --- a/render_kdenlive.py +++ b/render_kdenlive.py @@ -12,6 +12,12 @@ def get_propery(element, name): return element.xpath('property[@name="%s"]' % name)[0].text +def melt_xml(file): + if file in _CACHE: + out = _CACHE[file] + else: + out = _CACHE[file] = subprocess.check_output(['melt', file, '-consumer', 'xml']).decode() + return out class KDEnliveProject: @@ -423,10 +429,7 @@ class KDEnliveProject: return prefix + self.get_counter(prefix) def get_chain(self, file, kdenlive_id=None): - if file in _CACHE: - out = _CACHE[file] - else: - out = _CACHE[file] = subprocess.check_output(['melt', file, '-consumer', 'xml']).decode() + out = melt_xml(file) chain = lxml.etree.fromstring(out).xpath('producer')[0] chain.tag = 'chain' chain.attrib['id'] = self.get_id('chain') @@ -614,7 +617,7 @@ class KDEnliveProject: self.get_element("entry", attrib={ "producer": chain.attrib["id"], "in": chain.attrib["in"], - "out": str(frames), + "out": str(frames - 1) }, children=[ ["kdenlive:id", id], ] + filters_),