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
- while not _eod:
- _frames, _eod = _proc.process(*_decoder.process())
- yield _proc.chunk
- _flag.value = True
- _flag.save()
-
-def stream_from_file(__file):
+ proc.set_metadata(metadata)
+ eod = False
+ while not eod:
+ frames, eod = proc.process(*decoder.process())
+ yield proc.chunk
+ flag.value = True
+ flag.save()
+
+def stream_from_file(file):
chunk_size = 0x100000
- f = open(__file, 'r')
+ f = open(file, 'r')
while True:
- __chunk = f.read(chunk_size)
- if not len(__chunk):
+ chunk = f.read(chunk_size)
+ if not len(chunk):
f.close()
break
- yield __chunk
+ yield chunk
def get_public_access(access, year_from=None, year_to=None):
# Rolling publishing date : public access is given when time between recorded year
# Authors: Olivier Guilyardi <olivier@samalyse.com>
# Guillaume Pellerin <yomguy@parisson.com>
-
+import mimetypes
from telemeta.views.core import *
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()
analysis = MediaItemAnalysis(item=item, name='Channels',
analyzer_id='channels',
- unit='', value=decoder.channels())
+ unit='', value=decoder.input_channels)
analysis.save()
analysis = MediaItemAnalysis(item=item, name='Samplerate',
analyzer_id='samplerate', unit='Hz',
- value=unicode(decoder.audiorate))
+ value=unicode(decoder.input_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:
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)
except:
pass
response = HttpResponse(stream_from_file(audio), mimetype = mime_type)
-# fsock = open(audio, 'r')
-# response = HttpResponse(fsock, mimetype = mime_type)
else:
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())