Search in sources :

Example 6 with VideoTranscoding

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

the class VideoQualityTableFormController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source instanceof FormLink && ((FormLink) source).getCmd().equals("viewQuality")) {
        if (cmc == null) {
            // initialize preview controller only once
            previewVC = createVelocityContainer("video_preview");
            cmc = new CloseableModalController(getWindowControl(), "close", previewVC);
            listenTo(cmc);
        }
        // Get the user object from the link to access version object
        FormLink link = (FormLink) source;
        VideoTranscoding videoTranscoding = (VideoTranscoding) link.getUserObject();
        if (videoTranscoding == null) {
            // this is the master video
            // VideoMetadata videoMetadata = videoManager.readVideoMetadataFile(videoResource);
            VideoMeta videoMetadata = videoManager.getVideoMetadata(videoResource);
            previewVC.contextPut("width", videoMetadata.getWidth());
            previewVC.contextPut("height", videoMetadata.getHeight());
            previewVC.contextPut("filename", "video.mp4");
            VFSContainer container = videoManager.getMasterContainer(videoResource);
            String transcodedUrl = registerMapper(ureq, new VideoMediaMapper(container));
            previewVC.contextPut("mediaUrl", transcodedUrl);
        } else {
            // this is a version
            previewVC.contextPut("width", videoTranscoding.getWidth());
            previewVC.contextPut("height", videoTranscoding.getHeight());
            previewVC.contextPut("filename", videoTranscoding.getResolution() + "video.mp4");
            VFSContainer container = videoManager.getTranscodingContainer(videoResource);
            String transcodedUrl = registerMapper(ureq, new VideoMediaMapper(container));
            previewVC.contextPut("mediaUrl", transcodedUrl);
        }
        // activate dialog to bring it in front
        cmc.activate();
    } else if (source instanceof FormLink && ((FormLink) source).getCmd().equals("deleteQuality")) {
        FormLink link = (FormLink) source;
        VideoTranscoding videoTranscoding = (VideoTranscoding) link.getUserObject();
        videoManager.deleteVideoTranscoding(videoTranscoding);
    } else if (source instanceof FormLink && ((FormLink) source).getCmd().equals("startTranscoding")) {
        videoManager.createTranscoding(videoResource, (int) source.getUserObject(), "mp4");
    }
    initTable();
}
Also used : VideoMeta(org.olat.modules.video.VideoMeta) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) VideoTranscoding(org.olat.modules.video.VideoTranscoding) VFSContainer(org.olat.core.util.vfs.VFSContainer) VideoMediaMapper(org.olat.modules.video.manager.VideoMediaMapper) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 7 with VideoTranscoding

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

the class VideoManagerImpl method getMissingTranscodings.

@Override
public List<Integer> getMissingTranscodings(OLATResource videoResource) {
    // get resolutions which are turned on in the videomodule
    int[] configuredResolutions = videoModule.getTranscodingResolutions();
    // turn the int[]-Array into a List
    List<Integer> configResList = IntStream.of(configuredResolutions).boxed().collect(Collectors.toList());
    List<VideoTranscoding> videoTranscodings = getVideoTranscodings(videoResource);
    for (VideoTranscoding videoTranscoding : videoTranscodings) {
        Integer resolution = videoTranscoding.getResolution();
        configResList.remove(resolution);
    }
    return configResList;
}
Also used : VideoTranscoding(org.olat.modules.video.VideoTranscoding)

Example 8 with VideoTranscoding

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

the class VideoTranscodingJob method doExecute.

/**
 * Implementation of job execution
 * @param context
 * @return
 * @throws JobExecutionException
 */
private boolean doExecute(JobExecutionContext context) throws JobExecutionException {
    VideoModule videoModule = CoreSpringFactory.getImpl(VideoModule.class);
    if (!videoModule.isTranscodingLocal()) {
        log.debug("Skipping execution of video transcoding job, local transcoding disabled");
        return false;
    }
    // Find first one to work with
    boolean allOk = true;
    for (VideoTranscoding videoTranscoding = getNextVideo(); videoTranscoding != null; videoTranscoding = getNextVideo()) {
        allOk &= forkTranscodingProcess(videoTranscoding);
    }
    return allOk;
}
Also used : VideoTranscoding(org.olat.modules.video.VideoTranscoding) VideoModule(org.olat.modules.video.VideoModule)

Example 9 with VideoTranscoding

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

the class VideoTranscodingJob method getNextVideo.

private VideoTranscoding getNextVideo() {
    VideoManager videoManager = CoreSpringFactory.getImpl(VideoManager.class);
    List<VideoTranscoding> videoTranscodings = videoManager.getVideoTranscodingsPendingAndInProgress();
    VideoTranscoding videoTranscoding = null;
    for (VideoTranscoding videoTrans : videoTranscodings) {
        String transcoder = videoTrans.getTranscoder();
        if (transcoder == null) {
            log.info("Start transcoding video with resolution::" + videoTrans.getResolution() + " for video resource::" + videoTrans.getVideoResource().getResourceableId());
            videoTrans.setTranscoder(VideoTranscoding.TRANSCODER_LOCAL);
            videoTranscoding = videoManager.updateVideoTranscoding(videoTrans);
            break;
        } else if (transcoder.equals(VideoTranscoding.TRANSCODER_LOCAL)) {
            log.info("Continue with transcoding video with resolution::" + videoTrans.getResolution() + " for video resource::" + videoTrans.getVideoResource().getResourceableId());
            videoTranscoding = videoTrans;
            break;
        }
    }
    return videoTranscoding;
}
Also used : VideoTranscoding(org.olat.modules.video.VideoTranscoding) VideoManager(org.olat.modules.video.VideoManager)

Example 10 with VideoTranscoding

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

the class VideoTranscodingDAO method updateTranscodingStatus.

/**
 * Update transcoding status so TranscodingJob can find the resource.
 *
 * @param videoTranscoding
 * @return updated videoTranscoding
 */
VideoTranscoding updateTranscodingStatus(VideoTranscoding videoTranscoding) {
    ((VideoTranscodingImpl) videoTranscoding).setLastModified(new Date());
    videoTranscoding.setStatus(-1);
    VideoTranscoding trans = dbInstance.getCurrentEntityManager().merge(videoTranscoding);
    return trans;
}
Also used : VideoTranscodingImpl(org.olat.modules.video.model.VideoTranscodingImpl) VideoTranscoding(org.olat.modules.video.VideoTranscoding) Date(java.util.Date)

Aggregations

VideoTranscoding (org.olat.modules.video.VideoTranscoding)34 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)12 ArrayList (java.util.ArrayList)8 Date (java.util.Date)8 OLATResource (org.olat.resource.OLATResource)8 Test (org.junit.Test)6 VideoMeta (org.olat.modules.video.VideoMeta)6 HashMap (java.util.HashMap)4 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 VideoMediaMapper (org.olat.modules.video.manager.VideoMediaMapper)4 VideoTranscodingImpl (org.olat.modules.video.model.VideoTranscodingImpl)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 HashSet (java.util.HashSet)2 Set (java.util.Set)2 Size (org.olat.core.commons.services.image.Size)2 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 VideoManager (org.olat.modules.video.VideoManager)2 VideoModule (org.olat.modules.video.VideoModule)2 SchedulerException (org.quartz.SchedulerException)2