use of org.olat.modules.video.VideoMeta in project openolat by klemens.
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.VideoMeta in project OpenOLAT by OpenOLAT.
the class VideoManagerImpl method setPosterframeResizeUploadfile.
/**
* Sets the posterframe resize uploadfile. Tries to fit image to dimensions of video.
*
* @param videoResource the video resource
* @param posterframe the newPosterFile
*/
@Override
public void setPosterframeResizeUploadfile(OLATResource videoResource, VFSLeaf newPosterFile) {
VideoMeta videoMetadata = getVideoMetadata(videoResource);
Size posterRes = imageHelper.getSize(newPosterFile, FILETYPE_JPG);
// file size needs to be bigger than target resolution, otherwise use image as it comes
if (posterRes != null && posterRes.getHeight() != 0 && posterRes.getWidth() != 0 && posterRes.getHeight() >= videoMetadata.getHeight() && posterRes.getWidth() >= videoMetadata.getWidth()) {
VFSLeaf oldPosterFile = getPosterframe(videoResource);
oldPosterFile.delete();
VFSContainer masterContainer = getMasterContainer(videoResource);
LocalFileImpl newPoster = (LocalFileImpl) masterContainer.createChildLeaf(FILENAME_POSTER_JPG);
// to shrink image file, resolution ratio needs to be equal, otherwise crop from top left corner
if (posterRes.getHeight() / posterRes.getWidth() == videoMetadata.getHeight() / videoMetadata.getWidth()) {
imageHelper.scaleImage(newPosterFile, newPoster, videoMetadata.getWidth(), videoMetadata.getHeight(), true);
} else {
Crop cropSelection = new Crop(0, 0, videoMetadata.getHeight(), videoMetadata.getWidth());
imageHelper.cropImage(((LocalFileImpl) newPosterFile).getBasefile(), newPoster.getBasefile(), cropSelection);
}
} else {
setPosterframe(videoResource, newPosterFile);
}
}
use of org.olat.modules.video.VideoMeta in project OpenOLAT by OpenOLAT.
the class VideoManagerImpl method startTranscodingProcess.
@Override
public void startTranscodingProcess(OLATResource video) {
List<VideoTranscoding> existingTranscodings = getVideoTranscodings(video);
VideoMeta videoMetadata = getVideoMetadata(video);
int height = videoMetadata.getHeight();
// 1) setup transcoding job for original file size
createTranscodingIfNotCreatedAlready(video, height, VideoTranscoding.FORMAT_MP4, existingTranscodings);
// 2) setup transcoding jobs for all configured sizes below the original size
int[] resolutions = videoModule.getTranscodingResolutions();
for (int resolution : resolutions) {
if (height <= resolution) {
continue;
}
createTranscodingIfNotCreatedAlready(video, resolution, VideoTranscoding.FORMAT_MP4, existingTranscodings);
}
// 3) Start transcoding immediately, force job execution
if (videoModule.isTranscodingLocal()) {
try {
scheduler.triggerJob(videoJobKey);
} catch (SchedulerException e) {
log.error("Error while starting video transcoding job", e);
}
}
}
use of org.olat.modules.video.VideoMeta in project OpenOLAT by OpenOLAT.
the class VideoMetadataDAOTest method deleteVideoMetadata.
@Test
public void deleteVideoMetadata() {
RepositoryEntry entry0 = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry entry1 = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry entry2 = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry entry3 = JunitTestHelper.createAndPersistRepositoryEntry();
// create metadata entries
VideoMeta meta0 = videoMetadataDao.createVideoMetadata(entry0, 1500, "vid.mp4");
VideoMeta meta1 = videoMetadataDao.createVideoMetadata(entry1, 1100, "vide.mp4");
VideoMeta meta2 = videoMetadataDao.createVideoMetadata(entry2, 1200, "video.mov");
VideoMeta meta3 = videoMetadataDao.createVideoMetadata(entry3, 4500, "videos.mp4");
Assert.assertNotNull(meta1);
Assert.assertNotNull(meta3);
Assert.assertNotNull(meta2);
Assert.assertNotNull(meta0);
dbInstance.commitAndCloseSession();
// retrieve list of entries
List<VideoMetaImpl> metadata = videoMetadataDao.getAllVideoResourcesMetadata();
Assert.assertTrue(metadata.contains(meta0));
Assert.assertTrue(metadata.contains(meta1));
Assert.assertTrue(metadata.contains(meta2));
Assert.assertTrue(metadata.contains(meta3));
// delete entries
int deleted0 = videoMetadataDao.deleteVideoMetadata(entry0.getOlatResource());
int deleted3 = videoMetadataDao.deleteVideoMetadata(entry3.getOlatResource());
Assert.assertEquals(1, deleted0);
Assert.assertNotEquals(0, deleted3);
dbInstance.commitAndCloseSession();
// retrieve new list
List<VideoMetaImpl> deleteMetadata = videoMetadataDao.getAllVideoResourcesMetadata();
Assert.assertFalse(deleteMetadata.contains(meta0));
Assert.assertTrue(deleteMetadata.contains(meta1));
Assert.assertTrue(deleteMetadata.contains(meta2));
Assert.assertFalse(deleteMetadata.contains(meta3));
}
use of org.olat.modules.video.VideoMeta in project openolat by klemens.
the class VideoManagerImpl method startTranscodingProcess.
@Override
public void startTranscodingProcess(OLATResource video) {
List<VideoTranscoding> existingTranscodings = getVideoTranscodings(video);
VideoMeta videoMetadata = getVideoMetadata(video);
int height = videoMetadata.getHeight();
// 1) setup transcoding job for original file size
createTranscodingIfNotCreatedAlready(video, height, VideoTranscoding.FORMAT_MP4, existingTranscodings);
// 2) setup transcoding jobs for all configured sizes below the original size
int[] resolutions = videoModule.getTranscodingResolutions();
for (int resolution : resolutions) {
if (height <= resolution) {
continue;
}
createTranscodingIfNotCreatedAlready(video, resolution, VideoTranscoding.FORMAT_MP4, existingTranscodings);
}
// 3) Start transcoding immediately, force job execution
if (videoModule.isTranscodingLocal()) {
try {
scheduler.triggerJob(videoJobKey);
} catch (SchedulerException e) {
log.error("Error while starting video transcoding job", e);
}
}
}
Aggregations