forked from 0x2620/pandora
extract sequences from all parts
This commit is contained in:
parent
e21484af1c
commit
cde92a1624
2 changed files with 21 additions and 15 deletions
|
@ -50,13 +50,12 @@ def get_hash(image, mode, debug=False):
|
||||||
if h.endswith('L'): h = h[:-1]
|
if h.endswith('L'): h = h[:-1]
|
||||||
return '0' * (16-len(h)) + h
|
return '0' * (16-len(h)) + h
|
||||||
|
|
||||||
def get_sequences(path):
|
def get_sequences(path, position=0):
|
||||||
modes = ['color', 'shape']
|
modes = ['color', 'shape']
|
||||||
sequences = {}
|
sequences = {}
|
||||||
for mode in modes:
|
for mode in modes:
|
||||||
sequences[mode] = []
|
sequences[mode] = []
|
||||||
fps = 25
|
fps = 25
|
||||||
position = 0
|
|
||||||
file_names = filter(lambda x: 'timelinedata8p' in x, os.listdir(path))
|
file_names = filter(lambda x: 'timelinedata8p' in x, os.listdir(path))
|
||||||
file_names = sorted(file_names, key=lambda x: int(x[14:-4]))
|
file_names = sorted(file_names, key=lambda x: int(x[14:-4]))
|
||||||
file_names = map(lambda x: path + x, file_names)
|
file_names = map(lambda x: path + x, file_names)
|
||||||
|
@ -75,5 +74,5 @@ def get_sequences(path):
|
||||||
for mode in modes:
|
for mode in modes:
|
||||||
if sequences[mode]:
|
if sequences[mode]:
|
||||||
sequences[mode][-1]['out'] = position
|
sequences[mode][-1]['out'] = position
|
||||||
return sequences
|
return sequences, position
|
||||||
|
|
||||||
|
|
|
@ -14,11 +14,13 @@ from celery.task import task, periodic_task
|
||||||
import models
|
import models
|
||||||
import extract
|
import extract
|
||||||
|
|
||||||
@task(ignore_results=True, queue='default')
|
@task(ignore_results=True, queue='encoding')
|
||||||
def get_sequences(itemId):
|
def get_sequences(itemId):
|
||||||
i = models.Item.objects.get(itemId=itemId)
|
i = models.Item.objects.get(itemId=itemId)
|
||||||
models.Sequence.objects.filter(item=i).delete()
|
models.Sequence.objects.filter(item=i).delete()
|
||||||
data = extract.get_sequences(i.timeline_prefix)
|
position = 0
|
||||||
|
for stream in i.streams():
|
||||||
|
data, position = extract.get_sequences(stream.timeline_prefix, position)
|
||||||
with transaction.commit_on_success():
|
with transaction.commit_on_success():
|
||||||
for mode in data:
|
for mode in data:
|
||||||
for seq in data[mode]:
|
for seq in data[mode]:
|
||||||
|
@ -29,3 +31,8 @@ def get_sequences(itemId):
|
||||||
s.end = seq['out']
|
s.end = seq['out']
|
||||||
s.hash = seq['hash']
|
s.hash = seq['hash']
|
||||||
s.save()
|
s.save()
|
||||||
|
|
||||||
|
@task(ignore_results=True, queue='encoding')
|
||||||
|
def update_sequence_ids(itemId):
|
||||||
|
for s in models.Sequence.objects.filter(item__itemId=itemId):
|
||||||
|
s.save()
|
||||||
|
|
Loading…
Reference in a new issue