From c6a37f7ab52c390978f589e32872aafc04e52646 Mon Sep 17 00:00:00 2001 From: yomguy Date: Thu, 27 Sep 2012 02:29:34 +0200 Subject: [PATCH] fix decoder properties for analyzing against timeside gst branch --- telemeta/views/core.py | 2 +- telemeta/views/item.py | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/telemeta/views/core.py b/telemeta/views/core.py index ad5b5931..e3a7b745 100644 --- a/telemeta/views/core.py +++ b/telemeta/views/core.py @@ -106,7 +106,7 @@ def render(request, template, data = None, mimetype = None): return render_to_response(template, data, context_instance=RequestContext(request), mimetype=mimetype) -def stream_from_processor(_decoder, proc, flag, metadata=None): +def stream_from_processor(decoder, proc, flag, metadata=None): if metadata: proc.set_metadata(metadata) eod = False diff --git a/telemeta/views/item.py b/telemeta/views/item.py index 6e2b71ba..c85c22ea 100644 --- a/telemeta/views/item.py +++ b/telemeta/views/item.py @@ -34,7 +34,7 @@ # Authors: Olivier Guilyardi # Guillaume Pellerin - +import mimetypes from telemeta.views.core import * class ItemView(object): @@ -381,7 +381,7 @@ class ItemView(object): grapher['graph'].render(grapher['path']) f.close() - mime_type = decoder.format() + mime_type = mimetypes.guess_type(item.file.path)[0] analysis = MediaItemAnalysis(item=item, name='MIME type', analyzer_id='mime_type', unit='', value=mime_type) analysis.save() @@ -391,15 +391,15 @@ class ItemView(object): analysis.save() analysis = MediaItemAnalysis(item=item, name='Samplerate', analyzer_id='samplerate', unit='Hz', - value=unicode(decoder.audiorate)) + value=unicode(decoder.samplerate())) analysis.save() analysis = MediaItemAnalysis(item=item, name='Resolution', analyzer_id='resolution', unit='bits', - value=unicode(decoder.audiowidth)) + value=unicode(decoder.input_width)) analysis.save() analysis = MediaItemAnalysis(item=item, name='Duration', analyzer_id='duration', unit='s', - value=unicode(datetime.timedelta(0,decoder.duration))) + value=unicode(datetime.timedelta(0,decoder.input_duration))) analysis.save() for analyzer in analyzers_sub: @@ -443,10 +443,9 @@ class ItemView(object): if not self.cache_data.exists(image_file): if item.file: path = self.cache_data.dir + os.sep + image_file - decoder = timeside.decoder.FileDecoder(item.file.path) + decoder = self.decoders[0](item.file.path) graph = grapher(width = int(width), height = int(height)) - pipe = decoder | graph - pipe.run() + (decoder | graph).run() graph.watermark('timeside', opacity=.6, margin=(5,5)) f = open(path, 'w') graph.render(path) @@ -533,7 +532,7 @@ class ItemView(object): media = self.cache_export.dir + os.sep + file if not self.cache_export.exists(file) or not flag.value: # source > encoder > stream - decoder = timeside.decoder.FileDecoder(audio) + decoder = self.decoders[0](audio) decoder.setup() proc = encoder(media, streaming=True) proc.setup(channels=decoder.channels(), samplerate=decoder.samplerate()) -- 2.39.5