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();
}
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;
}
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;
}
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;
}
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;
}
Aggregations