rebuild timelines in encoding pipe

This commit is contained in:
j 2012-06-06 16:38:18 +02:00
parent 3f59138c66
commit d543e35f3f
3 changed files with 15 additions and 9 deletions

View file

@ -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

View file

@ -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)

View file

@ -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((