Compare commits

..

3 commits

Author SHA1 Message Date
j
12c27dbb48 remove audio special case 2026-02-03 18:15:45 +01:00
j
4faef5e1dd move after render 2026-02-03 18:15:08 +01:00
j
00f6b9b4f4 image stuff 2026-02-03 18:13:06 +01:00
2 changed files with 37 additions and 16 deletions

View file

@ -492,6 +492,35 @@ def process_frame(item, prompt, character=None, position=0, seed=None):
img.update_find() img.update_find()
return img 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): def replace_background(image, background, prompt=None, seed=None):
model = "seedream-4-5-251128" model = "seedream-4-5-251128"
position = 0 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 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): def fal_replace_character(item, character, position=0):
if isinstance(item, str): if isinstance(item, str):

View file

@ -556,10 +556,11 @@ def render_all(options):
if '/audio' in timeline: if '/audio' in timeline:
ext = '.wav' ext = '.wav'
out = '%s' % timeline.replace('.kdenlive', ext) out = '%s' % timeline.replace('.kdenlive', ext)
tmp_out = '%s' % timeline.replace('.kdenlive', ".tmp" + ext)
cmd = get_melt() + [ cmd = get_melt() + [
timeline, timeline,
'-quiet', '-quiet',
'-consumer', 'avformat:%s' % out, '-consumer', 'avformat:%s' % tmp_out,
] ]
if ext == '.wav': if ext == '.wav':
cmd += ['vn=1'] cmd += ['vn=1']
@ -571,20 +572,7 @@ def render_all(options):
cmd += ['vcodec=libx264', 'x264opts=keyint=1', 'crf=15'] cmd += ['vcodec=libx264', 'x264opts=keyint=1', 'crf=15']
if needs_update(timeline, out): if needs_update(timeline, out):
subprocess.call(cmd) subprocess.call(cmd)
if ext == '.wav' and timeline.endswith('audio.kdenlive'): shutil.move(tmp_out, out)
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 = [] cmds = []
fragment_prefix = Path(fragment_prefix) fragment_prefix = Path(fragment_prefix)
@ -695,9 +683,10 @@ def render_all(options):
if '/audio' in timelines[0]: if '/audio' in timelines[0]:
ext = '.wav' ext = '.wav'
out = base_prefix / (timeline + ext) out = base_prefix / (timeline + ext)
tmp_out = base_prefix / (timeline + ".tmp" +ext)
cmd = get_melt() + timelines + [ cmd = get_melt() + timelines + [
'-quiet', '-quiet',
'-consumer', 'avformat:%s' % out, '-consumer', 'avformat:%s' % tmp_out,
] ]
if ext == '.wav': if ext == '.wav':
cmd += ['vn=1'] cmd += ['vn=1']
@ -709,6 +698,7 @@ def render_all(options):
cmd += ['vcodec=libx264', 'x264opts=keyint=1', 'crf=15'] cmd += ['vcodec=libx264', 'x264opts=keyint=1', 'crf=15']
if needs_update(timelines[0], out): if needs_update(timelines[0], out):
cmds.append(cmd) cmds.append(cmd)
shutil.move(tmp_out, out)
for src, out1, out2 in ( for src, out1, out2 in (
("audio-front.wav", "fl.wav", "fr.wav"), ("audio-front.wav", "fl.wav", "fr.wav"),