Search in sources :

Example 16 with VideoMeta

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

the class VideoMetaDataEditFormController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("tab.video.metaDataConfig");
    OLATResource videoResource = repoEntry.getOlatResource();
    VideoMeta videoMetadata = videoManager.getVideoMetadata(videoResource);
    uifactory.addStaticTextElement("video.config.duration", repoEntry.getExpenditureOfWork(), formLayout);
    uifactory.addStaticTextElement("video.config.width", String.valueOf(videoMetadata.getWidth()) + "px", formLayout);
    uifactory.addStaticTextElement("video.config.height", String.valueOf(videoMetadata.getHeight()) + "px", formLayout);
    String aspcectRatio = videoManager.getAspectRatio(videoMetadata.getWidth(), videoMetadata.getHeight());
    uifactory.addStaticTextElement("video.config.ratio", aspcectRatio, formLayout);
    uifactory.addStaticTextElement("video.config.creationDate", StringHelper.formatLocaleDateTime(videoResource.getCreationDate().getTime(), getLocale()), formLayout);
    uifactory.addStaticTextElement("video.config.fileSize", Formatter.formatBytes(videoManager.getVideoFile(videoResource).length()), formLayout);
}
Also used : VideoMeta(org.olat.modules.video.VideoMeta) OLATResource(org.olat.resource.OLATResource)

Example 17 with VideoMeta

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

the class VideoQualityTableFormController method initTable.

private void initTable() {
    List<QualityTableRow> rows = new ArrayList<>();
    VideoMeta videoMetadata = videoManager.getVideoMetadata(videoResource);
    // Add master video file
    FormLink previewMasterLink = uifactory.addFormLink("view", "viewQuality", "quality.master", "quality.master", flc, Link.LINK);
    Object[] statusMaster = new Object[] { 100, Formatter.formatBytes(videoManager.getVideoFile(videoResource).length()) };
    rows.add(new QualityTableRow(previewMasterLink, videoMetadata.getWidth() + "x" + videoMetadata.getHeight(), statusMaster, "mp4", null));
    // Add all the transcoded versions
    List<VideoTranscoding> videoTranscodings = videoManager.getVideoTranscodings(videoResource);
    for (VideoTranscoding videoTranscoding : videoTranscodings) {
        String title = videoManager.getDisplayTitleForResolution(videoTranscoding.getResolution(), getTranslator());
        FormLink previewVersionLink = uifactory.addFormLink("res_" + count++, "viewQuality", title, title, flc, Link.LINK + Link.NONTRANSLATED);
        FormLink deleteLink = uifactory.addFormLink("del_" + count++, "deleteQuality", "quality.delete", "quality.delete", flc, Link.LINK);
        deleteLink.setUserObject(videoTranscoding);
        deleteLink.setIconLeftCSS("o_icon o_icon_delete_item o_icon-fw");
        previewVersionLink.setUserObject(videoTranscoding);
        if (videoTranscoding.getStatus() < VideoTranscoding.TRANSCODING_STATUS_DONE) {
            previewVersionLink.setEnabled(false);
        }
        int width = videoTranscoding.getWidth();
        int height = videoTranscoding.getHeight();
        String dimension = width + "x" + height;
        String fileSize = "";
        int status = videoTranscoding.getStatus();
        if (videoTranscoding.getSize() != 0 && status > -1) {
            fileSize = Formatter.formatBytes(videoTranscoding.getSize());
        } else if (status == VideoTranscoding.TRANSCODING_STATUS_WAITING) {
            fileSize = translate("transcoding.waiting");
        } else if (status <= VideoTranscoding.TRANSCODING_STATUS_DONE && status > -1) {
            fileSize = translate("transcoding.processing") + ": " + videoTranscoding.getStatus() + "%";
        } else if (status == VideoTranscoding.TRANSCODING_STATUS_INEFFICIENT) {
            fileSize = translate("transcoding.inefficient");
        } else if (status == VideoTranscoding.TRANSCODING_STATUS_ERROR) {
            fileSize = translate("transcoding.error");
        } else if (status == VideoTranscoding.TRANSCODING_STATUS_TIMEOUT) {
            fileSize = translate("transcoding.timeout");
        }
        Object[] statusTranscoding = new Object[] { status, fileSize };
        rows.add(new QualityTableRow(previewVersionLink, dimension, statusTranscoding, videoTranscoding.getFormat(), deleteLink));
    }
    List<Integer> missingResolutions = videoManager.getMissingTranscodings(videoResource);
    if (videoModule.isTranscodingEnabled()) {
        for (Integer missingRes : missingResolutions) {
            if (missingRes <= videoMetadata.getHeight()) {
                String title = videoManager.getDisplayTitleForResolution(missingRes, getTranslator());
                FormLink transcodeLink = uifactory.addFormLink("res_" + count++, "startTranscoding", "quality.transcode", "quality.transcode", flc, Link.LINK);
                transcodeLink.setUserObject(missingRes);
                transcodeLink.setIconLeftCSS("o_icon o_icon_refresh o_icon-fw");
                FormLink previewMissingLink = uifactory.addFormLink("res_" + count++, "viewQuality", title, title, flc, Link.LINK + Link.NONTRANSLATED);
                previewMissingLink.setEnabled(false);
                Object[] status = new Object[] { -1, "-" };
                rows.add(new QualityTableRow(previewMissingLink, missingRes.toString(), status, "mp4", transcodeLink));
            }
        }
    }
    rows.sort(new VideoComparator());
    tableModel.setObjects(rows);
    if (flc.hasFormComponent(tableEl)) {
        flc.remove(tableEl);
    }
    if (flc.hasFormComponent(refreshbtn)) {
        flc.remove(refreshbtn);
    }
    tableEl = uifactory.addTableElement(getWindowControl(), "qualityTable", tableModel, getTranslator(), flc);
    tableEl.setCustomizeColumns(false);
    tableEl.setNumOfRowsEnabled(false);
    refreshbtn = uifactory.addFormLink("button.refresh", flc, Link.BUTTON);
    refreshbtn.setIconLeftCSS("o_icon o_icon_refresh o_icon-fw");
}
Also used : VideoMeta(org.olat.modules.video.VideoMeta) VideoTranscoding(org.olat.modules.video.VideoTranscoding) ArrayList(java.util.ArrayList) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 18 with VideoMeta

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

the class VideoMetadataDAOTest method createVideoMetadata.

@Test
public void createVideoMetadata() {
    RepositoryEntry entry1 = JunitTestHelper.createAndPersistRepositoryEntry();
    RepositoryEntry entry2 = JunitTestHelper.createAndPersistRepositoryEntry();
    // create metadata entries
    VideoMeta meta1 = videoMetadataDao.createVideoMetadata(entry1, 1500, "vid.mp4");
    Assert.assertNotNull(meta1);
    VideoMeta meta2 = videoMetadataDao.createVideoMetadata(entry2, 5500, "vid.mov");
    Assert.assertNotNull(meta2);
    dbInstance.commitAndCloseSession();
    // retrieve by olat resource
    VideoMeta reloadMeta1 = videoMetadataDao.getVideoMetadata(entry1.getOlatResource());
    Assert.assertNotNull(reloadMeta1);
    Assert.assertEquals(1500, reloadMeta1.getSize());
}
Also used : VideoMeta(org.olat.modules.video.VideoMeta) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Aggregations

VideoMeta (org.olat.modules.video.VideoMeta)18 Size (org.olat.core.commons.services.image.Size)6 VideoTranscoding (org.olat.modules.video.VideoTranscoding)6 Test (org.junit.Test)4 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)4 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Crop (org.olat.core.commons.services.image.Crop)2 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)2 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)2 VideoMediaMapper (org.olat.modules.video.manager.VideoMediaMapper)2 VideoMetaImpl (org.olat.modules.video.model.VideoMetaImpl)2 OLATResource (org.olat.resource.OLATResource)2 SchedulerException (org.quartz.SchedulerException)2