limit memory usage for large timelines, sort parts, dont delete poster after creating it
This commit is contained in:
parent
41cf9ec744
commit
16b998f760
2 changed files with 19 additions and 15 deletions
|
@ -818,7 +818,7 @@ class Item(models.Model):
|
||||||
|
|
||||||
def streams(self):
|
def streams(self):
|
||||||
return [video.streams.filter(source=None, available=True)[0]
|
return [video.streams.filter(source=None, available=True)[0]
|
||||||
for video in self.files.filter(is_video=True, active=True)]
|
for video in self.files.filter(is_video=True, active=True).order_by('part')]
|
||||||
|
|
||||||
def update_timeline(self, force=False):
|
def update_timeline(self, force=False):
|
||||||
config = site_config()
|
config = site_config()
|
||||||
|
@ -938,7 +938,8 @@ class Item(models.Model):
|
||||||
p = subprocess.Popen(cmd)
|
p = subprocess.Popen(cmd)
|
||||||
p.wait()
|
p.wait()
|
||||||
for f in glob(poster.replace('.jpg', '*.jpg')):
|
for f in glob(poster.replace('.jpg', '*.jpg')):
|
||||||
os.unlink(f)
|
if f != poster:
|
||||||
|
os.unlink(f)
|
||||||
return poster
|
return poster
|
||||||
|
|
||||||
def poster_frames(self):
|
def poster_frames(self):
|
||||||
|
|
|
@ -78,22 +78,25 @@ def join_timelines(timelines, prefix):
|
||||||
for timeline in timelines:
|
for timeline in timelines:
|
||||||
tiles += sorted(glob('%s.%s.*.png'%(timeline, height)))
|
tiles += sorted(glob('%s.%s.*.png'%(timeline, height)))
|
||||||
|
|
||||||
tiles = map(Image.open, tiles)
|
timeline = Image.new("RGB", (2 * width, height))
|
||||||
duration = sum(map(lambda i: i.size[0], tiles))
|
|
||||||
timeline = Image.new("RGB", (duration, height))
|
|
||||||
pos = 0
|
|
||||||
for tile in tiles:
|
|
||||||
timeline.paste(tile, (pos, 0, pos+tile.size[0], height))
|
|
||||||
pos += tile.size[0]
|
|
||||||
|
|
||||||
pos = 0
|
pos = 0
|
||||||
i = 0
|
i = 0
|
||||||
while pos < timeline.size[0]:
|
for tile in tiles:
|
||||||
end = min(pos+width, timeline.size[0])
|
tile = Image.open(tile)
|
||||||
timeline_name = '%s.%s.%04d.png' % (prefix, timeline.size[1], i)
|
timeline.paste(tile, (pos, 0, pos+tile.size[0], height))
|
||||||
timeline.crop((pos, 0, end, timeline.size[1])).save(timeline_name)
|
pos += tile.size[0]
|
||||||
pos += width
|
if pos >= width:
|
||||||
i += 1
|
timeline_name = '%s.%s.%04d.png' % (prefix, height, i)
|
||||||
|
timeline.crop((0, 0, width, height)).save(timeline_name)
|
||||||
|
i += 1
|
||||||
|
if pos > width:
|
||||||
|
t = timeline.crop((width, 0, pos, height))
|
||||||
|
timeline.paste(t, (0, 0, t.size[0], height))
|
||||||
|
pos -= width
|
||||||
|
if pos:
|
||||||
|
timeline_name = '%s.%s.%04d.png' % (prefix, height, i)
|
||||||
|
timeline.crop((0, 0, pos, height)).save(timeline_name)
|
||||||
|
|
||||||
makeTiles(prefix, 16, 3600)
|
makeTiles(prefix, 16, 3600)
|
||||||
makeTimelineOverview(prefix, 1920, height=16)
|
makeTimelineOverview(prefix, 1920, height=16)
|
||||||
|
|
Loading…
Reference in a new issue