From d543e35f3fa3ade2f06b3ac684a11e1e32e7d3de Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 6 Jun 2012 16:38:18 +0200 Subject: [PATCH] rebuild timelines in encoding pipe --- .../item/management/commands/rebuild_timelines.py | 15 +++++++-------- pandora/item/tasks.py | 7 +++++++ pandora/item/timelines.py | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/pandora/item/management/commands/rebuild_timelines.py b/pandora/item/management/commands/rebuild_timelines.py index 69f0a3efc..46b3500f1 100644 --- a/pandora/item/management/commands/rebuild_timelines.py +++ b/pandora/item/management/commands/rebuild_timelines.py @@ -4,13 +4,14 @@ import os from os.path import join, dirname, basename, splitext, exists import time +from glob import glob from django.core.management.base import BaseCommand, CommandError from django.conf import settings import monkey_patch.models from ... import models - +from ... import tasks class Command(BaseCommand): """ @@ -21,14 +22,12 @@ class Command(BaseCommand): def handle(self, **options): offset = 0 - chunk = 50 + chunk = 100 count = pos = models.Item.objects.count() while offset <= count: for i in models.Item.objects.all().order_by('id')[offset:offset+chunk]: - print pos, i.itemId - for s in i.streams(): - s.make_timeline() - i.update_timeline() - pos -= 1 + if not os.path.exists(os.path.join(i.timeline_prefix, 'cuts.json')) or \ + not glob('%s/timelinekeyframes16p0.jpg'%i.timeline_prefix): + print i.itemId + tasks.rebuild_timeline.delay(i.itemId) offset += chunk - time.sleep(30) #keep load down diff --git a/pandora/item/tasks.py b/pandora/item/tasks.py index df50eef2e..1cd5ca119 100644 --- a/pandora/item/tasks.py +++ b/pandora/item/tasks.py @@ -64,6 +64,13 @@ def update_timeline(itemId): item = models.Item.objects.get(itemId=itemId) item.update_timeline() +@task(queue="encoding") +def rebuild_timeline(itemId): + i = models.Item.objects.get(itemId=itemId) + for s in i.streams(): + s.make_timeline() + i.update_timeline() + @task(queue="encoding") def load_subtitles(itemId): item = models.Item.objects.get(itemId=itemId) diff --git a/pandora/item/timelines.py b/pandora/item/timelines.py index 5346c5982..014ecb509 100644 --- a/pandora/item/timelines.py +++ b/pandora/item/timelines.py @@ -82,7 +82,7 @@ def join_tiles(source_paths, target_path): target_path, small_mode, small_tile_h, small_tile_i ) data['target_images']['small'].save(image_file) - print image_file + #print image_file if mode == 'antialias': # render full tile resized = data['target_images']['large'].resize((