only get sequences for audio. fix offset calculation

This commit is contained in:
j 2014-04-11 12:05:57 +00:00
parent be7ecc4a03
commit 4dca348b6e
2 changed files with 27 additions and 27 deletions

View file

@ -99,7 +99,7 @@ class DataTimeline():
x = frame * 8 - tile * self.timeline_width
return self.timeline_image.crop((x, 0, x + 8, 8))
def get_cut_sequences(stream, position=0):
def get_cut_sequences(stream):
timeline = DataTimeline(stream.timeline_prefix)
cuts = list(stream.cuts) + [stream.duration]
modes = ['color', 'shape']
@ -120,4 +120,4 @@ def get_cut_sequences(stream, position=0):
'out': cut,
})
position = cut
return sequences, position
return sequences

View file

@ -13,28 +13,28 @@ def get_sequences(itemId):
models.Sequence.objects.filter(sort=i.sort).delete()
position = 0
for stream in i.streams():
#data, position = extract.get_sequences(stream.timeline_prefix, position)
data, position = extract.get_cut_sequences(stream, position)
keys = None
values = []
for mode in data:
for s in data[mode]:
sequence = {
'sort_id': i.sort.pk,
'mode': models.Sequence.MODE[mode],
'start': float('%0.03f' % s['in']),
'end': float('%0.03f' % s['out']),
'hash': models.parse_hash(s['hash'])
}
sequence['duration'] = sequence['end'] - sequence['start']
if not keys:
keys = ', '.join(['"%s"'%k for k in sequence.keys()])
v = ', '.join([isinstance(v, basestring) and "'%s'"%v or str(v)
for v in sequence.values()])
values.append('(%s)'%v)
if values:
cursor = connection.cursor()
sql = "INSERT INTO sequence_sequence (%s) VALUES %s" % (keys, ', '.join(values));
cursor.execute(sql)
transaction.commit_unless_managed()
if stream.file.is_video:
data = extract.get_cut_sequences(stream)
keys = None
values = []
for mode in data:
for s in data[mode]:
sequence = {
'sort_id': i.sort.pk,
'mode': models.Sequence.MODE[mode],
'start': position + float('%0.03f' % s['in']),
'end': position + float('%0.03f' % s['out']),
'hash': models.parse_hash(s['hash'])
}
sequence['duration'] = sequence['end'] - sequence['start']
if not keys:
keys = ', '.join(['"%s"'%k for k in sequence.keys()])
v = ', '.join([isinstance(v, basestring) and "'%s'"%v or str(v)
for v in sequence.values()])
values.append('(%s)'%v)
if values:
cursor = connection.cursor()
sql = "INSERT INTO sequence_sequence (%s) VALUES %s" % (keys, ', '.join(values));
cursor.execute(sql)
transaction.commit_unless_managed()
position += stream.duration