diff --git a/management/commands/generate_clips.py b/management/commands/generate_clips.py index caec151..02a6f2d 100644 --- a/management/commands/generate_clips.py +++ b/management/commands/generate_clips.py @@ -10,6 +10,18 @@ import item.models import itemlist.models +def resolve_roman(s): + extra = re.compile('^\d+(.*?)$').findall(s) + if extra: + extra = extra[0].lower() + new = { + 'i': '1', 'ii': '2', 'iii': '3', 'iv': '4', 'v': '5', + 'vi': '6', 'vii': 7, 'viii': '8', 'ix': '9', 'x': '10' + }.get(extra, extra) + return s.replace(extra, new) + return s + + class Command(BaseCommand): help = 'generate symlinks to clips and clips.json' @@ -44,8 +56,12 @@ class Command(BaseCommand): clip['editingtags'] = i.data.get('editingtags', []) name = os.path.basename(clip['original']) - seqid = re.sub("Hotel Aporia_(\d+)", "S\\1_", name).split('_')[:2] + seqid = re.sub("Hotel Aporia_(\d+)", "S\\1_", name) + seqid = re.sub("Night March_(\d+)", "S\\1_", seqid) + seqid = re.sub("_(\d+)H_(\d+)", "_S\\1\\2_", seqid) + seqid = seqid.split('_')[:2] seqid = [b[1:] if b[0] in ('B', 'S') else '0' for b in seqid] + seqid[1] = resolve_roman(seqid[1]) seqid[1] = ''.join([b for b in seqid[1] if b.isdigit()]) if not seqid[1]: seqid[1] = '0' diff --git a/render.py b/render.py index aa0c491..9bc19cd 100644 --- a/render.py +++ b/render.py @@ -111,12 +111,9 @@ def compose(clips, target=150, base=1024, voice_over=None): if "foreground" not in clip and "animation" in clip: fg = clip['animation'] + transparancy = 1 else: fg = clip['foreground'] - if 'foley' in clip: - foley = clip['foley'] - else: - foley = fg if 'foreground2' in clip: if 'foreground3' in clip: n = seq() @@ -128,12 +125,16 @@ def compose(clips, target=150, base=1024, voice_over=None): clip['foreground3'] elif chance(seq, 0.5): fg = clip['foreground2'] - - scene['front']['V1'].append({ + transparancy = seq() / 10 + if 'foley' in clip: + foley = clip['foley'] + else: + foley = fg + scene['front']['V2'].append({ 'duration': clip['duration'], 'src': fg, "filter": { - 'transparency': seq() / 10, + 'transparency': transparancy, } }) @@ -145,15 +146,16 @@ def compose(clips, target=150, base=1024, voice_over=None): else: transparency_back = transparency transparency_front = 0 + transparency_original = seq() / 10 if "background" in clip: - scene['front']['V2'].append({ + scene['front']['V1'].append({ 'duration': clip['duration'], 'src': clip['background'], "filter": { 'transparency': transparency_front } }) - scene['back']['V1'].append({ + scene['back']['V2'].append({ 'duration': clip['duration'], 'src': clip['background'], "filter": { @@ -161,27 +163,33 @@ def compose(clips, target=150, base=1024, voice_over=None): } }) else: - scene['front']['V2'].append({ - 'blank': True, + scene['front']['V1'].append({ 'duration': clip['duration'], + 'src': clip['animation'], + "filter": { + 'transparency': 0, + } }) - scene['back']['V1'].append({ - 'blank': True, + scene['back']['V2'].append({ 'duration': clip['duration'], + 'src': clip['original'], + "filter": { + 'transparency': 0, + } }) - scene['back']['V2'].append({ + scene['back']['V1'].append({ 'duration': clip['duration'], 'src': clip['original'], "filter": { - 'transparency': seq() / 10, + 'transparency': transparency_original, } }) # 50 % chance to blur original from 0 to 30 if chance(seq, 0.5): blur = seq() * 3 if blur: - scene['back']['V2'][-1]['filter']['blur'] = blur + scene['back']['V1'][-1]['filter']['blur'] = blur scene['audio']['A1'].append({ 'duration': clip['duration'], 'src': clip['original'], diff --git a/render_kdenlive.py b/render_kdenlive.py index 726550c..6eb9067 100644 --- a/render_kdenlive.py +++ b/render_kdenlive.py @@ -235,9 +235,9 @@ class KDEnliveProject: ["disable", "1"], ]), ]), - v2 := self.get_element("playlist", children=[ + v1 := self.get_element("playlist", children=[ ]), - v2e := self.get_element("playlist", children=[ + v1e := self.get_element("playlist", children=[ ]), t2 := self.get_element("tractor", attrib={ "in": "00:00:00.000", @@ -249,12 +249,12 @@ class KDEnliveProject: ["kdenlive:thumbs_format", None], ["kdenlive:audio_rec", None], ["kdenlive:locked_track", None], - self.get_element("track", attrib={"hide": "audio", "producer": v2.attrib["id"]}), - self.get_element("track", attrib={"hide": "audio", "producer": v2e.attrib["id"]}), + self.get_element("track", attrib={"hide": "audio", "producer": v1.attrib["id"]}), + self.get_element("track", attrib={"hide": "audio", "producer": v1e.attrib["id"]}), ]), - v1 := self.get_element("playlist", children=[ + v2 := self.get_element("playlist", children=[ ]), - v1e := self.get_element("playlist", children=[ + v2e := self.get_element("playlist", children=[ ]), t3 := self.get_element("tractor", attrib={ "in": "00:00:00.000" @@ -265,8 +265,8 @@ class KDEnliveProject: ["kdenlive:thumbs_format", None], ["kdenlive:audio_rec", None], ["kdenlive:locked_track", None], - self.get_element("track", attrib={"hide": "audio", "producer": v1.attrib["id"]}), - self.get_element("track", attrib={"hide": "audio", "producer": v1e.attrib["id"]}), + self.get_element("track", attrib={"hide": "audio", "producer": v2.attrib["id"]}), + self.get_element("track", attrib={"hide": "audio", "producer": v2e.attrib["id"]}), ]), sequence := self.get_element("tractor", [ ["kdenlive:uuid", self._uuid],