diff --git a/src/main/java/org/olat/modules/video/VideoModule.java b/src/main/java/org/olat/modules/video/VideoModule.java index 5de25406d858c347c7fe8bed609aaed191322104..bce9862581dff150803e924edc92683cd01b2e6b 100644 --- a/src/main/java/org/olat/modules/video/VideoModule.java +++ b/src/main/java/org/olat/modules/video/VideoModule.java @@ -72,6 +72,8 @@ public class VideoModule extends AbstractSpringModule { private String transcodingDir; @Value("${video.transcoding.resolution.preferred}") private String transcodingPreferredResolutionConf; + @Value("${video.transcoding.profile}") + private String transcodingProfile; private int[] transcodingResolutionsArr; //= new int[] { 1080,720,480,360 }; private Integer preferredDefaultResolution;// = new Integer(720); @@ -133,6 +135,9 @@ public class VideoModule extends AbstractSpringModule { preferredDefaultResolution = getIntPropertyValue(PREFERRED_RESOLUTION); } + // clean setting of injected config + setVideoTranscodingProfile(this.transcodingProfile); + log.info("video.enabled=" + isEnabled()); log.info("video.coursenode.enabled=" + isCoursenodeEnabled()); @@ -141,6 +146,7 @@ public class VideoModule extends AbstractSpringModule { log.info("video.transcoding.resolution.preferred=" + getPreferredDefaultResolution()); log.info("video.transcoding.taskset.cpuconfig=" + getTranscodingTasksetConfig()); log.info("video.transcoding.local=" + isTranscodingLocal()); + log.info("video.transcoding.profile=" + getVideoTranscodingProfile()); // Register video site for activation in top navigation NewControllerFactory.getInstance().addContextEntryControllerCreator(VideoSite.class.getSimpleName(), @@ -262,5 +268,22 @@ public class VideoModule extends AbstractSpringModule { this.transcodingLocal = transcodingLocal; setStringProperty(VIDEOTRANSCODING_LOCAL, Boolean.toString(transcodingLocal), true); } + + public void setVideoTranscodingProfile(String profile) { + if (StringHelper.containsNonWhitespace(profile)) { + if (profile.equals("Fast")) { + this.transcodingProfile = "Fast"; + return; + } else if (profile.equals("Very Fast")) { + this.transcodingProfile = "Very Fast"; + return; + } + } + this.transcodingProfile = "Fast"; // default; + } + + public String getVideoTranscodingProfile() { + return this.transcodingProfile; + } } diff --git a/src/main/java/org/olat/modules/video/manager/VideoTranscodingJob.java b/src/main/java/org/olat/modules/video/manager/VideoTranscodingJob.java index 280e5c8bed7557b6e84d8f982f842f5da650d263..65c39bd95abe1def5df8fe5b75d285f2d0cba922 100644 --- a/src/main/java/org/olat/modules/video/manager/VideoTranscodingJob.java +++ b/src/main/java/org/olat/modules/video/manager/VideoTranscodingJob.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import org.hibernate.ObjectDeletedException; @@ -49,6 +50,7 @@ import org.quartz.JobExecutionException; * */ public class VideoTranscodingJob extends JobWithDB { + private ArrayList<String> resolutionsWithProfile = new ArrayList<String>(Arrays.asList("1080", "720", "480")); /** * @@ -124,6 +126,12 @@ public class VideoTranscodingJob extends JobWithDB { videoTranscoding.setTranscoder(VideoTranscoding.TRANSCODER_LOCAL); videoTranscoding = videoManager.updateVideoTranscoding(videoTranscoding); + String resolution = Integer.toString(videoTranscoding.getResolution()); + String profile = "Normal"; // Legacy fallback + if (resolutionsWithProfile.contains(resolution)) { + profile = videoModule.getVideoTranscodingProfile() + " " + resolution + "p30"; + } + ArrayList<String> cmd = new ArrayList<>(); String tasksetConfig = videoModule.getTranscodingTasksetConfig(); if (tasksetConfig != null && !"Mac OS X".equals(System.getProperty("os.name"))) { @@ -136,12 +144,12 @@ public class VideoTranscodingJob extends JobWithDB { cmd.add(masterFile.getAbsolutePath()); cmd.add("-o"); cmd.add(transcodedFile.getAbsolutePath()); - cmd.add("--optimize"); + cmd.add("--optimize"); // add video infos to header for web "fast start" cmd.add("--preset"); - cmd.add("Fast 1080p30"); + cmd.add(profile); cmd.add("--height"); - cmd.add(Integer.toString(videoTranscoding.getResolution())); - cmd.add("--crop"); + cmd.add(resolution); + cmd.add("--crop"); // do not crop cmd.add("0:0:0:0"); Process process = null; diff --git a/src/main/resources/serviceconfig/olat.properties b/src/main/resources/serviceconfig/olat.properties index ccf98d0c3815d71561b272d5d68a337ad29e87be..0bb0af027f63380c17ece81ac31fd1751c2122d9 100644 --- a/src/main/resources/serviceconfig/olat.properties +++ b/src/main/resources/serviceconfig/olat.properties @@ -1362,7 +1362,7 @@ video.site.enable=false video.transcoding.enabled=false # The transcoding process can run locally in s separate process using HandBrake. In that # case, the binary "HandBrakeCLI" must be installed in your system and available to the -# java environment of your system. +# java environment of your system. Only HandBrakeCLI in version > 1 is supported. # Alternatively, you can disable local transcoding and implement a shell script that runs # on another server which reads from the o_vid_transcoding table to separate transcoding # from the main server. For larger installations it is recommendet to run the transcoding @@ -1372,11 +1372,17 @@ video.transcoding.local=true video.transcoding.taskset.cpuconfig=0,1 video.transcoding.taskset.cpuconfig.values=0,1 to indicate usage of 2 cores, set empty value to disable taskset (e.g. on osx not available) # List of transcoding versions to be generated by the transcoder -video.transcoding.resolutions=1080,720,480,360 -video.transcoding.resolutions.values=2160,1080,720,480,360,240 +video.transcoding.resolutions=1080,720,480 +video.transcoding.resolutions.values=2160,1080,720,480 # The preferred resolution if multiple video versions are available and the user has no # customized setting. Should be a values from video.transcoding.resolutions video.transcoding.resolution.preferred=720 +# Which profile should be used while transcoding. "Fast" delivers better quality, but taks +# roughly twice the time for transcoding. "Fast" has about one third larger file size. In +# short: "Fast" for better quality at the cost or resources, "Very Fast" for smaller files +# at the cost of quality. +video.transcoding.profile=Very Fast +video.transcoding.profile.values=Fast,Very Fast # Where to store transcoded versions. This can be located on another path in case the # transcoding service is working on another physical server or you just want it to use # another (cheap) disk. By default it is also located in the olatdata dir.