]> git.parisson.com Git - telemeta.git/commitdiff
fix decoder properties for analyzing against timeside gst branch
authoryomguy <yomguy@parisson.com>
Thu, 27 Sep 2012 00:29:34 +0000 (02:29 +0200)
committeryomguy <yomguy@parisson.com>
Thu, 27 Sep 2012 00:29:34 +0000 (02:29 +0200)
telemeta/views/core.py
telemeta/views/item.py

index ad5b59317acc21469dcb474c53d4cbd3ab4f1764..e3a7b7454e77c4c4e4811f2aa45423794c8937df 100644 (file)
@@ -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
index 6e2b71ba543fd2e70c87d8bfc7aa730d20e314f7..c85c22ea48ed04fb6552c9349fada150e9bb7538 100644 (file)
@@ -34,7 +34,7 @@
 # Authors: Olivier Guilyardi <olivier@samalyse.com>
 #          Guillaume Pellerin <yomguy@parisson.com>
 
-
+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())