From 00f6b9b4f4885a7dd7409559372203f166699db6 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 3 Feb 2026 18:13:06 +0100 Subject: [PATCH 1/3] image stuff --- generate.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/generate.py b/generate.py index 52ca52d..ee2ff37 100644 --- a/generate.py +++ b/generate.py @@ -492,6 +492,35 @@ def process_frame(item, prompt, character=None, position=0, seed=None): img.update_find() return img +def process_image(document, prompt, character=None, position=0, seed=None): + model = "seedream-4-5-251128" + if isinstance(character, Document): + character = public_document_url(character) + image = public_document_url(document) + if character is not None: + image = [image, character] + data = { + "model": model, + "prompt": prompt, + "image": image, + "size": "2560x1440", + } + if seed: + data["seed"] = seed + url = bytedance_image_generation(data) + img = add_ai_image(document, position, url) + img.refresh_from_db() + img.data["model"] = model + img.data["prompt"] = prompt + img.data["source"] = document.get_id() + if character: + img.data["source"] += " " + character.split("?")[0] + print(img, img.data) + img.save() + img.update_sort() + img.update_find() + return img + def replace_background(image, background, prompt=None, seed=None): model = "seedream-4-5-251128" position = 0 @@ -538,6 +567,8 @@ REPLACE_CHARACTER_PROMPT = "Replace the foreground character in image 1 with the REPLACE_CHARACTER_PROMPT = "Replace the foreground character in image 1 with the character in image 2, keep the posture, clothing, background, light, atmosphere from image 1, but take the facial features and personality from image 2. Make sure the size of the character is adjusted since the new character is a child and make sure the size of the head matches the body. The quality of the image should be the same between foreground and background, adjust the quality of the character to match the background. Use the style of image 1 for the character: if image 1 is a photo make the character a real person, if image 1 is a drawing make the character a drawn character, if image 1 is a comic use a comic character, restore any blurred out regions of the image" +REPLACE_CHARACTER_PROMPT = "Replace the main character in image 1 with the character in image 2, keep the posture, clothing, background, light, atmosphere from image 1, but take the facial features and personality from image 2. Make sure the size of the character is adjusted since the new character is a child and make sure the size of the head matches the body. The quality of the image should be the same between foreground and background, adjust the quality of the character to match the background. Use the style of image 1 for the character: if image 1 is a photo make the character a real person, if image 1 is a drawing make the character a drawn character, if image 1 is a comic use a comic character, restore any blurred out regions of the image" + def fal_replace_character(item, character, position=0): if isinstance(item, str): From 4faef5e1dd768f3d93c43c9c2e48e5eb74f416bd Mon Sep 17 00:00:00 2001 From: j Date: Tue, 3 Feb 2026 18:15:08 +0100 Subject: [PATCH 2/3] move after render --- render.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/render.py b/render.py index 7c1d9ae..a77883f 100644 --- a/render.py +++ b/render.py @@ -556,10 +556,11 @@ def render_all(options): if '/audio' in timeline: ext = '.wav' out = '%s' % timeline.replace('.kdenlive', ext) + tmp_out = '%s' % timeline.replace('.kdenlive', ".tmp" + ext) cmd = get_melt() + [ timeline, '-quiet', - '-consumer', 'avformat:%s' % out, + '-consumer', 'avformat:%s' % tmp_out, ] if ext == '.wav': cmd += ['vn=1'] @@ -571,6 +572,7 @@ def render_all(options): cmd += ['vcodec=libx264', 'x264opts=keyint=1', 'crf=15'] if needs_update(timeline, out): subprocess.call(cmd) + shutil.move(tmp_out, out) if ext == '.wav' and timeline.endswith('audio.kdenlive'): cmd = [ 'ffmpeg', '-y', @@ -695,9 +697,10 @@ def render_all(options): if '/audio' in timelines[0]: ext = '.wav' out = base_prefix / (timeline + ext) + tmp_out = base_prefix / (timeline + ".tmp" +ext) cmd = get_melt() + timelines + [ '-quiet', - '-consumer', 'avformat:%s' % out, + '-consumer', 'avformat:%s' % tmp_out, ] if ext == '.wav': cmd += ['vn=1'] @@ -709,6 +712,7 @@ def render_all(options): cmd += ['vcodec=libx264', 'x264opts=keyint=1', 'crf=15'] if needs_update(timelines[0], out): cmds.append(cmd) + shutil.move(tmp_out, out) for src, out1, out2 in ( ("audio-front.wav", "fl.wav", "fr.wav"), From 12c27dbb4856234ebd410c8d04f4596a2c5dc8d1 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 3 Feb 2026 18:15:45 +0100 Subject: [PATCH 3/3] remove audio special case --- render.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/render.py b/render.py index a77883f..3d1e390 100644 --- a/render.py +++ b/render.py @@ -573,20 +573,6 @@ def render_all(options): if needs_update(timeline, out): subprocess.call(cmd) shutil.move(tmp_out, out) - if ext == '.wav' and timeline.endswith('audio.kdenlive'): - cmd = [ - 'ffmpeg', '-y', - '-nostats', '-loglevel', 'error', - '-i', - timeline.replace('.kdenlive', ext), - timeline.replace('.kdenlive', '.mp4') - ] - wav = timeline.replace('.kdenlive', ext) - mp4 = timeline.replace('.kdenlive', '.mp4') - if needs_update(wav, mp4): - subprocess.call(cmd) - if not options.get("keep_parts"): - os.unlink(wav) cmds = [] fragment_prefix = Path(fragment_prefix)