|
@@ -0,0 +1,213 @@
|
|
|
+
|
|
|
+namespace Publicate.Video {
|
|
|
+
|
|
|
+ public static Invercargill.Enumerable<EncodingProfile> construct_vp9_profiles() {
|
|
|
+ return Invercargill.ate(new EncodingProfile[] {
|
|
|
+ new Vp9Video1080pHighFramerateProfile (),
|
|
|
+ new Vp9Video1080pLowFramerateProfile (),
|
|
|
+ new Vp9Video720pProfile(),
|
|
|
+ new Vp9Video480pProfile(),
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ public class Vp9Video1080pHighFramerateProfile : EncodingProfile {
|
|
|
+
|
|
|
+ public override string[] get_first_pass_command (string input_path, string output_path) {
|
|
|
+ return get_command (input_path, output_path, 1);
|
|
|
+ }
|
|
|
+ public override string[] get_second_pass_command (string input_path, string output_path) {
|
|
|
+ return get_command (input_path, output_path, 2);
|
|
|
+ }
|
|
|
+ public override string output_name () {
|
|
|
+ return @"1080p_$(fps)fps.webm";
|
|
|
+ }
|
|
|
+ public override string version_label (){
|
|
|
+ return @"1080p$(fps) VP9";
|
|
|
+ }
|
|
|
+ public override bool suitable_for (VideoInfo info) {
|
|
|
+ return info.height >= 1080 && get_low_framerate (info.frame_rate) != info.frame_rate;
|
|
|
+ }
|
|
|
+ public override void setup_for (VideoInfo info) {
|
|
|
+ codec_names = "vp9, opus";
|
|
|
+ var width = (int) (info.ratio_frac * 1080);
|
|
|
+ size = @"$(width)x1080";
|
|
|
+ fps = info.frame_rate;
|
|
|
+ }
|
|
|
+
|
|
|
+ private string[] get_command(string input_path, string output_path, int pass) {
|
|
|
+ return new string[] {
|
|
|
+ "ffmpeg",
|
|
|
+ "-i", input_path,
|
|
|
+ "-r", fps.to_string(),
|
|
|
+ "-vf", @"scale=$(size)",
|
|
|
+ "-b:v", "3000k",
|
|
|
+ "-minrate", "1500k",
|
|
|
+ "-maxrate", "2610k",
|
|
|
+ "-tile-columns", "2",
|
|
|
+ "-g", "240",
|
|
|
+ "-threads", "8",
|
|
|
+ "-quality", "good",
|
|
|
+ "-crf", "31",
|
|
|
+ "-c:v", "libvpx-vp9",
|
|
|
+ "-c:a", "libopus",
|
|
|
+ "-pass", pass.to_string(),
|
|
|
+ "-speed", "4",
|
|
|
+ "-passlogfile", @"$(output_path).logfile",
|
|
|
+ "-y",
|
|
|
+ output_path
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public class Vp9Video1080pLowFramerateProfile : EncodingProfile {
|
|
|
+
|
|
|
+ public override string[] get_first_pass_command (string input_path, string output_path) {
|
|
|
+ return get_command (input_path, output_path, 1);
|
|
|
+ }
|
|
|
+ public override string[] get_second_pass_command (string input_path, string output_path) {
|
|
|
+ return get_command (input_path, output_path, 2);
|
|
|
+ }
|
|
|
+ public override string output_name () {
|
|
|
+ return @"1080p.webm";
|
|
|
+ }
|
|
|
+ public override string version_label (){
|
|
|
+ return @"1080p VP9";
|
|
|
+ }
|
|
|
+ public override bool suitable_for (VideoInfo info) {
|
|
|
+ return info.height >= 1080;
|
|
|
+ }
|
|
|
+ public override void setup_for (VideoInfo info) {
|
|
|
+ codec_names = "vp9, opus";
|
|
|
+ var width = (int) (info.ratio_frac * 1080);
|
|
|
+ size = @"$(width)x1080";
|
|
|
+ fps = get_low_framerate (info.frame_rate);
|
|
|
+ }
|
|
|
+
|
|
|
+ private string[] get_command(string input_path, string output_path, int pass) {
|
|
|
+ return new string[] {
|
|
|
+ "ffmpeg",
|
|
|
+ "-i", input_path,
|
|
|
+ "-r", fps.to_string(),
|
|
|
+ "-vf", @"scale=$(size)",
|
|
|
+ "-b:v", "1800k",
|
|
|
+ "-minrate", "900k",
|
|
|
+ "-maxrate", "2610k",
|
|
|
+ "-tile-columns", "2",
|
|
|
+ "-g", "240",
|
|
|
+ "-threads", "8",
|
|
|
+ "-quality", "good",
|
|
|
+ "-crf", "31",
|
|
|
+ "-c:v", "libvpx-vp9",
|
|
|
+ "-c:a", "libopus",
|
|
|
+ "-pass", pass.to_string(),
|
|
|
+ "-speed", "4",
|
|
|
+ "-passlogfile", @"$(output_path).logfile",
|
|
|
+ "-y",
|
|
|
+ output_path
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public class Vp9Video720pProfile : EncodingProfile {
|
|
|
+
|
|
|
+ public override string[] get_first_pass_command (string input_path, string output_path) {
|
|
|
+ return get_command (input_path, output_path, 1);
|
|
|
+ }
|
|
|
+ public override string[] get_second_pass_command (string input_path, string output_path) {
|
|
|
+ return get_command (input_path, output_path, 2);
|
|
|
+ }
|
|
|
+ public override string output_name () {
|
|
|
+ return @"720p.webm";
|
|
|
+ }
|
|
|
+ public override string version_label (){
|
|
|
+ return @"720p VP9";
|
|
|
+ }
|
|
|
+ public override bool suitable_for (VideoInfo info) {
|
|
|
+ return info.height >= 720;
|
|
|
+ }
|
|
|
+ public override void setup_for (VideoInfo info) {
|
|
|
+ codec_names = "vp9, opus";
|
|
|
+ var width = (int) (info.ratio_frac * 720);
|
|
|
+ size = @"$(width)x720";
|
|
|
+ fps = get_low_framerate (info.frame_rate);
|
|
|
+ }
|
|
|
+
|
|
|
+ private string[] get_command(string input_path, string output_path, int pass) {
|
|
|
+ return new string[] {
|
|
|
+ "ffmpeg",
|
|
|
+ "-i", input_path,
|
|
|
+ "-r", fps.to_string(),
|
|
|
+ "-vf", @"scale=$(size)",
|
|
|
+ "-b:v", "1024k",
|
|
|
+ "-minrate", "512k",
|
|
|
+ "-maxrate", "1485k",
|
|
|
+ "-tile-columns", "2",
|
|
|
+ "-g", "240",
|
|
|
+ "-threads", "8",
|
|
|
+ "-quality", "good",
|
|
|
+ "-crf", "32",
|
|
|
+ "-c:v", "libvpx-vp9",
|
|
|
+ "-c:a", "libopus",
|
|
|
+ "-pass", pass.to_string(),
|
|
|
+ "-speed", "4",
|
|
|
+ "-passlogfile", @"$(output_path).logfile",
|
|
|
+ "-y",
|
|
|
+ output_path
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public class Vp9Video480pProfile : EncodingProfile {
|
|
|
+
|
|
|
+ public override string[] get_first_pass_command (string input_path, string output_path) {
|
|
|
+ return get_command (input_path, output_path, 1);
|
|
|
+ }
|
|
|
+ public override string[] get_second_pass_command (string input_path, string output_path) {
|
|
|
+ return get_command (input_path, output_path, 2);
|
|
|
+ }
|
|
|
+ public override string output_name () {
|
|
|
+ return @"480p.webm";
|
|
|
+ }
|
|
|
+ public override string version_label (){
|
|
|
+ return @"480p VP9";
|
|
|
+ }
|
|
|
+ public override bool suitable_for (VideoInfo info) {
|
|
|
+ return info.height >= 480;
|
|
|
+ }
|
|
|
+ public override void setup_for (VideoInfo info) {
|
|
|
+ codec_names = "vp9, opus";
|
|
|
+ var width = (int) (info.ratio_frac * 480);
|
|
|
+ size = @"$(width)x480";
|
|
|
+ fps = get_low_framerate (info.frame_rate);
|
|
|
+ }
|
|
|
+
|
|
|
+ private string[] get_command(string input_path, string output_path, int pass) {
|
|
|
+ return new string[] {
|
|
|
+ "ffmpeg",
|
|
|
+ "-i", input_path,
|
|
|
+ "-r", fps.to_string(),
|
|
|
+ "-vf", @"scale=$(size)",
|
|
|
+ "-b:v", "750k",
|
|
|
+ "-minrate", "375k",
|
|
|
+ "-maxrate", "1088k",
|
|
|
+ "-tile-columns", "2",
|
|
|
+ "-g", "240",
|
|
|
+ "-threads", "8",
|
|
|
+ "-quality", "good",
|
|
|
+ "-crf", "33",
|
|
|
+ "-c:v", "libvpx-vp9",
|
|
|
+ "-c:a", "libopus",
|
|
|
+ "-pass", pass.to_string(),
|
|
|
+ "-speed", "4",
|
|
|
+ "-passlogfile", @"$(output_path).logfile",
|
|
|
+ "-y",
|
|
|
+ output_path
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|