def testHachoir(self):
     tt = time.time()
     # import
     import collective.flowplayer.metadata_extraction as metaex
     # parse
     file_handle.seek(0)
     metadata = metaex.parse_raw(file_handle)
     file_handle.close()
     assert((288, 360) == metaex.scale_from_metadata(metadata))
     print 'parse with metadata_extraction: ' + str(time.time() - tt)
Exemplo n.º 2
0
 def testHachoir(self):
     tt = time.time()
     # import
     import collective.flowplayer.metadata_extraction as metaex
     # parse
     file_handle.seek(0)
     metadata = metaex.parse_raw(file_handle)
     file_handle.close()
     assert ((288, 360) == metaex.scale_from_metadata(metadata))
     print 'parse with metadata_extraction: ' + str(time.time() - tt)
Exemplo n.º 3
0
def update_media_info(context, event):
    info = IPrimaryFieldInfo(context)
    anno = IAnnotations(context)
    ext = None
    if info.value is not None:
        parts = info.value.filename.rsplit('.', 1)
        if len(parts) == 2:
            ext = '.' + parts[1]
    if ext in AUDIO_EXTENSIONS:
        anno[MEDIA_INFO_KEY] = dict(audio_only=True)
    elif ext in VIDEO_EXTENSIONS:
        f = info.value.open()
        metadata = parse_raw(f)
        height, width = scale_from_metadata(metadata)
        anno[MEDIA_INFO_KEY] = dict(audio_only=False, width=width, height=height)
        f.close()
    else:
        if MEDIA_INFO_KEY in anno:
            del anno[MEDIA_INFO_KEY]
Exemplo n.º 4
0
    def handleVideo(self):
        video = IVideo.providedBy(self.content)
        
        if not video:
            alsoProvides(self.content, IVideo)
            self.object.reindexObject(idxs=['object_provides'])

        info = IMediaInfo(self.content)

        if (not video) or (info.height == None or info.width == None):
            handle = self.file_handle
            try:
                metadata = parse_raw(handle)
                height, width = scale_from_metadata(metadata)
                handle.close()
            except StreamError:
                height = width = None

            if height and width:
                info.height = height
                info.width = width            
def update_media_info(context, event):
    info = IPrimaryFieldInfo(context)
    anno = IAnnotations(context)
    ext = None
    if info.value is not None:
        parts = info.value.filename.rsplit('.', 1)
        if len(parts) == 2:
            ext = '.' + parts[1]
    if ext in AUDIO_EXTENSIONS:
        anno[MEDIA_INFO_KEY] = dict(audio_only=True)
    elif ext in VIDEO_EXTENSIONS:
        f = info.value.open()
        metadata = parse_raw(f)
        height, width = scale_from_metadata(metadata)
        anno[MEDIA_INFO_KEY] = dict(audio_only=False,
                                    width=width,
                                    height=height)
        f.close()
    else:
        if MEDIA_INFO_KEY in anno:
            del anno[MEDIA_INFO_KEY]
Exemplo n.º 6
0
    def handleVideo(self):
        video = IVideo.providedBy(self.content)

        if not video:
            alsoProvides(self.content, IVideo)
            self.object.reindexObject(idxs=['object_provides'])

        info = IMediaInfo(self.content)

        if (not video) or (info.height is None or info.width is None):
            handle = self.file_handle
            try:
                metadata = parse_raw(handle)
                height, width = scale_from_metadata(metadata)
                handle.close()
            except StreamError:
                height = width = None

            if height and width:
                info.height = height
                info.width = width