From: yomguy Date: Tue, 29 Mar 2011 23:21:44 +0000 (+0200) Subject: speed up forst process by adding the default waveform to the pipe X-Git-Tag: 1.1~313 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=d9f1d8d40e9afad78c7cc54bd189556ad9b91d62;p=telemeta.git speed up forst process by adding the default waveform to the pipe --- diff --git a/telemeta/web/base.py b/telemeta/web/base.py index 6d9a7f62..8275aa8e 100644 --- a/telemeta/web/base.py +++ b/telemeta/web/base.py @@ -389,6 +389,13 @@ class WebView(object): item.approx_duration = str(time) item.save() else: + # process first waveform to speed up imports + width = 360 + height = 130 + size = str(width) + '_' + str(height) + grapher_id = 'waveform' + image_file = '.'.join([public_id, grapher_id, size, 'png']) + analyzers = [] analyzers_sub = [] if item.file: @@ -398,7 +405,18 @@ class WebView(object): subpipe = analyzer() analyzers_sub.append(subpipe) pipe = pipe | subpipe + if not self.cache_data.exists(image_file): + path = self.cache_data.dir + os.sep + image_file + for grapher in self.graphers: + if grapher.id() == grapher_id: + break + graph = grapher(width = int(width), height = int(height)) + pipe = pipe | graph pipe.run() + if not self.cache_data.exists(image_file): + f = open(path, 'w') + graph.render(path) + f.close() mime_type = decoder.format() analyzers.append({'name': 'Mime type', 'id': 'mime_type', 'unit': '', 'value': mime_type}) analyzers.append({'name': 'Channels', 'id': 'channels', 'unit': '', 'value': decoder.channels()})