Compare commits
No commits in common. "4058ac84c12965f5420922cc5ab1915fb758d8af" and "3a367e8c734b693db43c94f27109cec9bde91a16" have entirely different histories.
4058ac84c1
...
3a367e8c73
2 changed files with 32 additions and 80 deletions
|
|
@ -1,6 +1,5 @@
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
|
@ -19,9 +18,9 @@ class Command(BaseCommand):
|
||||||
def handle(self, **options):
|
def handle(self, **options):
|
||||||
prefix = options['prefix']
|
prefix = options['prefix']
|
||||||
clips = []
|
clips = []
|
||||||
for i in item.models.Item.objects.filter(sort__type='original'):
|
for i in item.models.Item.objects.filter(data__type__contains="Original"):
|
||||||
qs = item.models.Item.objects.filter(data__title=i.data['title']).exclude(id=i.id)
|
qs = item.models.Item.objects.filter(data__title=i.data['title']).exclude(id=i.id)
|
||||||
if qs.count() >= 1:
|
if qs.count() >= 2:
|
||||||
clip = {}
|
clip = {}
|
||||||
durations = []
|
durations = []
|
||||||
for e in item.models.Item.objects.filter(data__title=i.data['title']):
|
for e in item.models.Item.objects.filter(data__title=i.data['title']):
|
||||||
|
|
@ -42,18 +41,6 @@ class Command(BaseCommand):
|
||||||
clip["duration"] = min(durations)
|
clip["duration"] = min(durations)
|
||||||
clip['tags'] = i.data.get('tags', [])
|
clip['tags'] = i.data.get('tags', [])
|
||||||
clip['editingtags'] = i.data.get('editingtags', [])
|
clip['editingtags'] = i.data.get('editingtags', [])
|
||||||
name = os.path.basename(clip['original'])
|
|
||||||
|
|
||||||
seqid = re.sub("Hotel Aporia_(\d+)", "S\\1_", name).split('_')[:2]
|
|
||||||
seqid = [b[1:] if b[0] in ('B', 'S') else '0' for b in seqid]
|
|
||||||
seqid[1] = ''.join([b for b in seqid[1] if b.isdigit()])
|
|
||||||
if not seqid[1]:
|
|
||||||
seqid[1] = '0'
|
|
||||||
try:
|
|
||||||
clip['seqid'] = int(''.join(['%06d' % int(b) for b in seqid]))
|
|
||||||
except:
|
|
||||||
print(name, seqid, 'failed')
|
|
||||||
raise
|
|
||||||
if "original" in clip and "foreground" in clip and "background" in clip:
|
if "original" in clip and "foreground" in clip and "background" in clip:
|
||||||
clips.append(clip)
|
clips.append(clip)
|
||||||
elif "original" in clip and "animation" in clip:
|
elif "original" in clip and "animation" in clip:
|
||||||
|
|
@ -64,8 +51,6 @@ class Command(BaseCommand):
|
||||||
with open(os.path.join(prefix, 'clips.json'), 'w') as fd:
|
with open(os.path.join(prefix, 'clips.json'), 'w') as fd:
|
||||||
json.dump(clips, fd, indent=2, ensure_ascii=False)
|
json.dump(clips, fd, indent=2, ensure_ascii=False)
|
||||||
|
|
||||||
print("using", len(clips), "clips")
|
|
||||||
|
|
||||||
voice_over = defaultdict(dict)
|
voice_over = defaultdict(dict)
|
||||||
for vo in item.models.Item.objects.filter(
|
for vo in item.models.Item.objects.filter(
|
||||||
data__type__contains="Voice Over",
|
data__type__contains="Voice Over",
|
||||||
|
|
|
||||||
93
render.py
93
render.py
|
|
@ -35,16 +35,6 @@ def random_choice(seq, items, pop=False):
|
||||||
def chance(seq, chance):
|
def chance(seq, chance):
|
||||||
return (seq() / 10) >= chance
|
return (seq() / 10) >= chance
|
||||||
|
|
||||||
def get_clip_by_seqid(clips, seqid):
|
|
||||||
selected = None
|
|
||||||
for i, clip in enumerate(clips):
|
|
||||||
if clip['seqid'] == seqid:
|
|
||||||
selected = i
|
|
||||||
break
|
|
||||||
if selected is not None:
|
|
||||||
return clips.pop(i)
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def compose(clips, target=150, base=1024, voice_over=None):
|
def compose(clips, target=150, base=1024, voice_over=None):
|
||||||
length = 0
|
length = 0
|
||||||
|
|
@ -90,17 +80,8 @@ def compose(clips, target=150, base=1024, voice_over=None):
|
||||||
for vo in voice_overs:
|
for vo in voice_overs:
|
||||||
scene['audio']['A3'].append(vo)
|
scene['audio']['A3'].append(vo)
|
||||||
|
|
||||||
clip = None
|
|
||||||
while target - length > 0 and clips:
|
while target - length > 0 and clips:
|
||||||
# coin flip which site is visible (50% chance)
|
clip = random_choice(seq, clips, True)
|
||||||
if clip:
|
|
||||||
if chance(seq, 0.5):
|
|
||||||
next_seqid = clip['seqid'] + 1
|
|
||||||
clip = get_clip_by_seqid(clips, next_seqid)
|
|
||||||
else:
|
|
||||||
clip = None
|
|
||||||
if not clip:
|
|
||||||
clip = random_choice(seq, clips, True)
|
|
||||||
if not clips:
|
if not clips:
|
||||||
clips = [c for c in all_clips if c != clip]
|
clips = [c for c in all_clips if c != clip]
|
||||||
if not clips:
|
if not clips:
|
||||||
|
|
@ -109,25 +90,22 @@ def compose(clips, target=150, base=1024, voice_over=None):
|
||||||
break
|
break
|
||||||
length += clip['duration']
|
length += clip['duration']
|
||||||
|
|
||||||
if "foreground" not in clip and "animation" in clip:
|
fg = clip['foreground']
|
||||||
fg = clip['animation']
|
if 'foley' in clip:
|
||||||
|
foley = clip['foley']
|
||||||
else:
|
else:
|
||||||
fg = clip['foreground']
|
foley = fg
|
||||||
if 'foley' in clip:
|
if 'foreground2' in clip:
|
||||||
foley = clip['foley']
|
if 'foreground3' in clip:
|
||||||
else:
|
n = seq()
|
||||||
foley = fg
|
if n <= 3: # 0,1,2,3
|
||||||
if 'foreground2' in clip:
|
clip['foreground']
|
||||||
if 'foreground3' in clip:
|
elif n <= 6: # 4,5,6
|
||||||
n = seq()
|
clip['foreground2']
|
||||||
if n <= 3: # 0,1,2,3
|
else: # 7,8,9
|
||||||
clip['foreground']
|
clip['foreground3']
|
||||||
elif n <= 6: # 4,5,6
|
elif chance(seq, 0.5):
|
||||||
clip['foreground2']
|
fg = clip['foreground2']
|
||||||
else: # 7,8,9
|
|
||||||
clip['foreground3']
|
|
||||||
elif chance(seq, 0.5):
|
|
||||||
fg = clip['foreground2']
|
|
||||||
|
|
||||||
scene['front']['V1'].append({
|
scene['front']['V1'].append({
|
||||||
'duration': clip['duration'],
|
'duration': clip['duration'],
|
||||||
|
|
@ -145,31 +123,20 @@ def compose(clips, target=150, base=1024, voice_over=None):
|
||||||
else:
|
else:
|
||||||
transparency_back = transparency
|
transparency_back = transparency
|
||||||
transparency_front = 0
|
transparency_front = 0
|
||||||
if "background" in clip:
|
scene['front']['V2'].append({
|
||||||
scene['front']['V2'].append({
|
'duration': clip['duration'],
|
||||||
'duration': clip['duration'],
|
'src': clip['background'],
|
||||||
'src': clip['background'],
|
"filter": {
|
||||||
"filter": {
|
'transparency': transparency_front
|
||||||
'transparency': transparency_front
|
}
|
||||||
}
|
})
|
||||||
})
|
scene['back']['V1'].append({
|
||||||
scene['back']['V1'].append({
|
'duration': clip['duration'],
|
||||||
'duration': clip['duration'],
|
'src': clip['background'],
|
||||||
'src': clip['background'],
|
"filter": {
|
||||||
"filter": {
|
'transparency': transparency_back
|
||||||
'transparency': transparency_back
|
}
|
||||||
}
|
})
|
||||||
})
|
|
||||||
else:
|
|
||||||
scene['front']['V2'].append({
|
|
||||||
'blank': True,
|
|
||||||
'duration': clip['duration'],
|
|
||||||
})
|
|
||||||
scene['back']['V1'].append({
|
|
||||||
'blank': True,
|
|
||||||
'duration': clip['duration'],
|
|
||||||
})
|
|
||||||
|
|
||||||
scene['back']['V2'].append({
|
scene['back']['V2'].append({
|
||||||
'duration': clip['duration'],
|
'duration': clip['duration'],
|
||||||
'src': clip['original'],
|
'src': clip['original'],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue