Skip to content
Snippets Groups Projects
Commit ccd5c9f6 authored by gnaegi's avatar gnaegi
Browse files

OO-3004 make handbrake transcoding profile configurable (fast and very fast)

parent 2a47213c
No related branches found
No related tags found
No related merge requests found
...@@ -72,6 +72,8 @@ public class VideoModule extends AbstractSpringModule { ...@@ -72,6 +72,8 @@ public class VideoModule extends AbstractSpringModule {
private String transcodingDir; private String transcodingDir;
@Value("${video.transcoding.resolution.preferred}") @Value("${video.transcoding.resolution.preferred}")
private String transcodingPreferredResolutionConf; private String transcodingPreferredResolutionConf;
@Value("${video.transcoding.profile}")
private String transcodingProfile;
private int[] transcodingResolutionsArr; //= new int[] { 1080,720,480,360 }; private int[] transcodingResolutionsArr; //= new int[] { 1080,720,480,360 };
private Integer preferredDefaultResolution;// = new Integer(720); private Integer preferredDefaultResolution;// = new Integer(720);
...@@ -133,6 +135,9 @@ public class VideoModule extends AbstractSpringModule { ...@@ -133,6 +135,9 @@ public class VideoModule extends AbstractSpringModule {
preferredDefaultResolution = getIntPropertyValue(PREFERRED_RESOLUTION); preferredDefaultResolution = getIntPropertyValue(PREFERRED_RESOLUTION);
} }
// clean setting of injected config
setVideoTranscodingProfile(this.transcodingProfile);
log.info("video.enabled=" + isEnabled()); log.info("video.enabled=" + isEnabled());
log.info("video.coursenode.enabled=" + isCoursenodeEnabled()); log.info("video.coursenode.enabled=" + isCoursenodeEnabled());
...@@ -141,6 +146,7 @@ public class VideoModule extends AbstractSpringModule { ...@@ -141,6 +146,7 @@ public class VideoModule extends AbstractSpringModule {
log.info("video.transcoding.resolution.preferred=" + getPreferredDefaultResolution()); log.info("video.transcoding.resolution.preferred=" + getPreferredDefaultResolution());
log.info("video.transcoding.taskset.cpuconfig=" + getTranscodingTasksetConfig()); log.info("video.transcoding.taskset.cpuconfig=" + getTranscodingTasksetConfig());
log.info("video.transcoding.local=" + isTranscodingLocal()); log.info("video.transcoding.local=" + isTranscodingLocal());
log.info("video.transcoding.profile=" + getVideoTranscodingProfile());
// Register video site for activation in top navigation // Register video site for activation in top navigation
NewControllerFactory.getInstance().addContextEntryControllerCreator(VideoSite.class.getSimpleName(), NewControllerFactory.getInstance().addContextEntryControllerCreator(VideoSite.class.getSimpleName(),
...@@ -262,5 +268,22 @@ public class VideoModule extends AbstractSpringModule { ...@@ -262,5 +268,22 @@ public class VideoModule extends AbstractSpringModule {
this.transcodingLocal = transcodingLocal; this.transcodingLocal = transcodingLocal;
setStringProperty(VIDEOTRANSCODING_LOCAL, Boolean.toString(transcodingLocal), true); 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;
}
} }
...@@ -25,6 +25,7 @@ import java.io.IOException; ...@@ -25,6 +25,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import org.hibernate.ObjectDeletedException; import org.hibernate.ObjectDeletedException;
...@@ -49,6 +50,7 @@ import org.quartz.JobExecutionException; ...@@ -49,6 +50,7 @@ import org.quartz.JobExecutionException;
* *
*/ */
public class VideoTranscodingJob extends JobWithDB { 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 { ...@@ -124,6 +126,12 @@ public class VideoTranscodingJob extends JobWithDB {
videoTranscoding.setTranscoder(VideoTranscoding.TRANSCODER_LOCAL); videoTranscoding.setTranscoder(VideoTranscoding.TRANSCODER_LOCAL);
videoTranscoding = videoManager.updateVideoTranscoding(videoTranscoding); 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<>(); ArrayList<String> cmd = new ArrayList<>();
String tasksetConfig = videoModule.getTranscodingTasksetConfig(); String tasksetConfig = videoModule.getTranscodingTasksetConfig();
if (tasksetConfig != null && !"Mac OS X".equals(System.getProperty("os.name"))) { if (tasksetConfig != null && !"Mac OS X".equals(System.getProperty("os.name"))) {
...@@ -136,12 +144,12 @@ public class VideoTranscodingJob extends JobWithDB { ...@@ -136,12 +144,12 @@ public class VideoTranscodingJob extends JobWithDB {
cmd.add(masterFile.getAbsolutePath()); cmd.add(masterFile.getAbsolutePath());
cmd.add("-o"); cmd.add("-o");
cmd.add(transcodedFile.getAbsolutePath()); cmd.add(transcodedFile.getAbsolutePath());
cmd.add("--optimize"); cmd.add("--optimize"); // add video infos to header for web "fast start"
cmd.add("--preset"); cmd.add("--preset");
cmd.add("Fast 1080p30"); cmd.add(profile);
cmd.add("--height"); cmd.add("--height");
cmd.add(Integer.toString(videoTranscoding.getResolution())); cmd.add(resolution);
cmd.add("--crop"); cmd.add("--crop"); // do not crop
cmd.add("0:0:0:0"); cmd.add("0:0:0:0");
Process process = null; Process process = null;
......
...@@ -1362,7 +1362,7 @@ video.site.enable=false ...@@ -1362,7 +1362,7 @@ video.site.enable=false
video.transcoding.enabled=false video.transcoding.enabled=false
# The transcoding process can run locally in s separate process using HandBrake. In that # 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 # 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 # 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 # 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 # from the main server. For larger installations it is recommendet to run the transcoding
...@@ -1372,11 +1372,17 @@ video.transcoding.local=true ...@@ -1372,11 +1372,17 @@ video.transcoding.local=true
video.transcoding.taskset.cpuconfig=0,1 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) 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 # List of transcoding versions to be generated by the transcoder
video.transcoding.resolutions=1080,720,480,360 video.transcoding.resolutions=1080,720,480
video.transcoding.resolutions.values=2160,1080,720,480,360,240 video.transcoding.resolutions.values=2160,1080,720,480
# The preferred resolution if multiple video versions are available and the user has no # The preferred resolution if multiple video versions are available and the user has no
# customized setting. Should be a values from video.transcoding.resolutions # customized setting. Should be a values from video.transcoding.resolutions
video.transcoding.resolution.preferred=720 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 # 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 # 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. # another (cheap) disk. By default it is also located in the olatdata dir.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment