Search in sources :

Example 1 with VideoMetadata

use of org.olat.modules.video.VideoMetadata in project OpenOLAT by OpenOLAT.

the class VideoManagerImpl method isMetadataFileValid.

@Override
public boolean isMetadataFileValid(OLATResource videoResource) {
    VFSContainer baseContainer = FileResourceManager.getInstance().getFileResourceRootImpl(videoResource);
    VFSLeaf metaDataFile = (VFSLeaf) baseContainer.resolve(FILENAME_VIDEO_METADATA_XML);
    try {
        VideoMetadata meta = (VideoMetadata) XStreamHelper.readObject(XStreamHelper.createXStreamInstance(), metaDataFile);
        return meta != null;
    } catch (Exception e) {
        return false;
    }
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) VideoMetadata(org.olat.modules.video.VideoMetadata) SchedulerException(org.quartz.SchedulerException) IOException(java.io.IOException)

Example 2 with VideoMetadata

use of org.olat.modules.video.VideoMetadata in project OpenOLAT by OpenOLAT.

the class VideoManagerImpl method readVideoMetadataFile.

@Override
public VideoMetadata readVideoMetadataFile(OLATResource videoResource) {
    VFSContainer baseContainer = FileResourceManager.getInstance().getFileResourceRootImpl(videoResource);
    VFSLeaf metaDataFile = (VFSLeaf) baseContainer.resolve(FILENAME_VIDEO_METADATA_XML);
    try {
        return (VideoMetadata) XStreamHelper.readObject(XStreamHelper.createXStreamInstance(), metaDataFile);
    } catch (Exception e) {
        log.error("Error while parsing XStream file for videoResource::" + videoResource, e);
        // return an empty, so at least it displays something and not an error
        VideoMetadata meta = new VideoMetadataImpl();
        meta.setWidth(800);
        meta.setHeight(600);
        return meta;
    }
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) VideoMetadataImpl(org.olat.modules.video.model.VideoMetadataImpl) VideoMetadata(org.olat.modules.video.VideoMetadata) SchedulerException(org.quartz.SchedulerException) IOException(java.io.IOException)

Example 3 with VideoMetadata

use of org.olat.modules.video.VideoMetadata in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_11_3_0 method processVideoResource.

private boolean processVideoResource(RepositoryEntry entry) {
    try {
        OLATResource videoResource = entry.getOlatResource();
        if (!videoManager.hasMasterContainer(videoResource)) {
            log.error("RepoEntry: " + entry.getKey() + " has no valid master container.");
            // log error but return true to proceed
            return true;
        }
        // update track files on file system
        VFSContainer masterContainer = videoManager.getMasterContainer(videoResource);
        if (videoManager.isMetadataFileValid(videoResource)) {
            VideoMetadata metafromXML = videoManager.readVideoMetadataFile(videoResource);
            for (Entry<String, String> track : metafromXML.getAllTracks().entrySet()) {
                VFSItem item = masterContainer.resolve(track.getValue());
                if (item != null && item instanceof VFSLeaf) {
                    String path = VideoManagerImpl.TRACK + track.getKey() + VideoManagerImpl.DOT + FilenameUtils.getExtension(track.getValue());
                    // check if modified track file already exists
                    if (masterContainer.resolve(path) == null) {
                        VFSLeaf target = masterContainer.createChildLeaf(path);
                        VFSManager.copyContent((VFSLeaf) item, target);
                    }
                }
            }
        } else {
            log.error("RepoEntry: " + entry.getKey() + " has no valid Video Metadata XML file.");
        }
        // create meta data entries on database
        if (videoManager.hasVideoFile(videoResource)) {
            File videoFile = videoManager.getVideoFile(videoResource);
            String fileName = videoFile.getName();
            long size = videoFile.length();
            String format = FilenameUtils.getExtension(fileName);
            if (videoManager.hasVideoMetadata(videoResource)) {
                VideoMetaImpl entity = new VideoMetaImpl();
                entity.setVideoResource(videoResource);
                entity.setFormat(format);
                entity.setCreationDate(new Date());
                entity.setLastModified(new Date());
                Size resolution = videoManager.getVideoResolutionFromOLATResource(videoResource);
                entity.setHeight(resolution.getHeight());
                entity.setWidth(resolution.getWidth());
                entity.setSize(size);
                entity.setLength(entry.getExpenditureOfWork());
                dbInstance.getCurrentEntityManager().persist(entity);
            }
        } else {
            log.error("RepoEntry: " + entry.getKey() + " has no valid resource.");
        }
        return true;
    } catch (Exception e) {
        log.error("Update Metadata failed", e);
        return false;
    }
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) Size(org.olat.core.commons.services.image.Size) VFSContainer(org.olat.core.util.vfs.VFSContainer) OLATResource(org.olat.resource.OLATResource) VFSItem(org.olat.core.util.vfs.VFSItem) VideoMetadata(org.olat.modules.video.VideoMetadata) Date(java.util.Date) VideoMetaImpl(org.olat.modules.video.model.VideoMetaImpl) File(java.io.File)

Example 4 with VideoMetadata

use of org.olat.modules.video.VideoMetadata in project openolat by klemens.

the class VideoManagerImpl method readVideoMetadataFile.

@Override
public VideoMetadata readVideoMetadataFile(OLATResource videoResource) {
    VFSContainer baseContainer = FileResourceManager.getInstance().getFileResourceRootImpl(videoResource);
    VFSLeaf metaDataFile = (VFSLeaf) baseContainer.resolve(FILENAME_VIDEO_METADATA_XML);
    try {
        return (VideoMetadata) XStreamHelper.readObject(XStreamHelper.createXStreamInstance(), metaDataFile);
    } catch (Exception e) {
        log.error("Error while parsing XStream file for videoResource::" + videoResource, e);
        // return an empty, so at least it displays something and not an error
        VideoMetadata meta = new VideoMetadataImpl();
        meta.setWidth(800);
        meta.setHeight(600);
        return meta;
    }
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) VideoMetadataImpl(org.olat.modules.video.model.VideoMetadataImpl) VideoMetadata(org.olat.modules.video.VideoMetadata) SchedulerException(org.quartz.SchedulerException) IOException(java.io.IOException)

Example 5 with VideoMetadata

use of org.olat.modules.video.VideoMetadata in project openolat by klemens.

the class VideoManagerImpl method isMetadataFileValid.

@Override
public boolean isMetadataFileValid(OLATResource videoResource) {
    VFSContainer baseContainer = FileResourceManager.getInstance().getFileResourceRootImpl(videoResource);
    VFSLeaf metaDataFile = (VFSLeaf) baseContainer.resolve(FILENAME_VIDEO_METADATA_XML);
    try {
        VideoMetadata meta = (VideoMetadata) XStreamHelper.readObject(XStreamHelper.createXStreamInstance(), metaDataFile);
        return meta != null;
    } catch (Exception e) {
        return false;
    }
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) VideoMetadata(org.olat.modules.video.VideoMetadata) SchedulerException(org.quartz.SchedulerException) IOException(java.io.IOException)

Aggregations

VFSContainer (org.olat.core.util.vfs.VFSContainer)6 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)6 VideoMetadata (org.olat.modules.video.VideoMetadata)6 IOException (java.io.IOException)4 SchedulerException (org.quartz.SchedulerException)4 File (java.io.File)2 Date (java.util.Date)2 Size (org.olat.core.commons.services.image.Size)2 VFSItem (org.olat.core.util.vfs.VFSItem)2 VideoMetaImpl (org.olat.modules.video.model.VideoMetaImpl)2 VideoMetadataImpl (org.olat.modules.video.model.VideoMetadataImpl)2 OLATResource (org.olat.resource.OLATResource)2