Commit bfd6e6ec authored by Andrey Filippov's avatar Andrey Filippov

Added video bitrate - new ffmpeg does not work with 0

parent 51c23b62
......@@ -2696,8 +2696,8 @@ public class CuasMotion {
String video_ext = clt_parameters.imp.video_ext;
String video_codec = clt_parameters.imp.video_codec.toLowerCase();
int video_crf = clt_parameters.imp.video_crf;
double video_bitrate_m = clt_parameters.imp.video_bitrate_m;
boolean remove_avi = clt_parameters.imp.remove_avi;
boolean dry_run = false;
String avi_path = null;
......
......@@ -855,6 +855,7 @@ min_str_neib_fpn 0.35
public String video_codec = "vp8";
public int video_crf = 40; // lower - better, larger file size
public boolean remove_avi = true; // remove avi after conversion to webm
public double video_bitrate_m = 50; // video bitrate in megabits/sec
public String video_codec_combo = "vp8"; // applies when combining videos
public int video_crf_combo = 40; // lower - better, larger file size applies when combining videos
public boolean add_average = true;
......@@ -2493,6 +2494,9 @@ min_str_neib_fpn 0.35
gd.addNumericField("Video CRF", this.video_crf, 0,3,"",
"Quality - the lower the better. 40 - OK");
gd.addNumericField("Video bitrate", this.video_bitrate_m, 5,7,"Mbps",
"Specify video bitrate in megabits per second, latter M will be added (0 does not work anymore).");
gd.addCheckbox ("Remove AVI", this.remove_avi,
"Remove large AVI files after (and only) conversion with ffmpeg.");
......@@ -3464,6 +3468,7 @@ min_str_neib_fpn 0.35
this.video_ext= gd.getNextString();
this.video_codec= gd.getNextString();
this.video_crf = (int) gd.getNextNumber();
this.video_bitrate_m = gd.getNextNumber();
this.remove_avi = gd.getNextBoolean();
this.video_codec_combo= gd.getNextString();
this.video_crf_combo = (int) gd.getNextNumber();
......@@ -4412,6 +4417,7 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"video_ext", this.video_ext+""); // String
properties.setProperty(prefix+"video_codec", this.video_codec+""); // String
properties.setProperty(prefix+"video_crf", this.video_crf+""); // int
properties.setProperty(prefix+"video_bitrate_m", this.video_bitrate_m+""); // double
properties.setProperty(prefix+"remove_avi", this.remove_avi+""); // boolean
properties.setProperty(prefix+"video_codec_combo", this.video_codec_combo+""); // String
properties.setProperty(prefix+"video_crf_combo", this.video_crf_combo+""); // int
......@@ -5343,6 +5349,8 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"video_ext")!=null) this.video_ext=(String) properties.getProperty(prefix+"video_ext");
if (properties.getProperty(prefix+"video_codec")!=null) this.video_codec=(String) properties.getProperty(prefix+"video_codec");
if (properties.getProperty(prefix+"video_crf")!=null) this.video_crf=Integer.parseInt(properties.getProperty(prefix+"video_crf"));
if (properties.getProperty(prefix+"video_bitrate_m")!=null) this.video_bitrate_m=Double.parseDouble(properties.getProperty(prefix+"video_bitrate_m"));
if (properties.getProperty(prefix+"remove_avi")!=null) this.remove_avi=Boolean.parseBoolean(properties.getProperty(prefix+"remove_avi"));
if (properties.getProperty(prefix+"video_codec_combo")!=null) this.video_codec_combo=(String) properties.getProperty(prefix+"video_codec_combo");
if (properties.getProperty(prefix+"video_crf_combo")!=null) this.video_crf_combo=Integer.parseInt(properties.getProperty(prefix+"video_crf_combo"));
......@@ -6269,6 +6277,7 @@ min_str_neib_fpn 0.35
imp.video_ext = this.video_ext;
imp.video_codec = this.video_codec;
imp.video_crf = this.video_crf;
imp.video_bitrate_m = this.video_bitrate_m;
imp.remove_avi = this.remove_avi;
imp.video_codec_combo = this.video_codec_combo;
imp.video_crf_combo = this.video_crf_combo;
......
......@@ -4814,6 +4814,8 @@ public class OpticalFlow {
String video_ext = clt_parameters.imp.video_ext;
String video_codec = clt_parameters.imp.video_codec.toLowerCase();
int video_crf = clt_parameters.imp.video_crf;
double video_bitrate_m = clt_parameters.imp.video_bitrate_m;
boolean remove_avi = clt_parameters.imp.remove_avi;
boolean um_mono = clt_parameters.imp.um_mono;
double um_sigma = clt_parameters.imp.um_sigma;
......@@ -6677,8 +6679,8 @@ public class OpticalFlow {
stereo_meta = " -metadata:s:v:0 stereo_mode=anaglyph_cyan_red ";
}
String shellCommand = String.format("ffmpeg -y -i %s -c %s -b:v 0 -crf %d %s %s",
avi_path, video_codec, video_crf, stereo_meta, webm_path);
String shellCommand = String.format("ffmpeg -y -i %s -c %s -b:v %fM -crf %d %s %s",
avi_path, video_codec, video_bitrate_m, video_crf, stereo_meta, webm_path);
Process p = null;
if (generate_mapped) {
int exit_code = -1;
......
......@@ -8581,6 +8581,7 @@ if (debugLevel > -100) return true; // temporarily !
double stereo_phone_width = clt_parameters.imp.stereo_phone_width; // 0 - no padding
boolean stereo_pad = (stereo_intereye > 0) && (stereo_phone_width > 0);
int video_crf_combo = clt_parameters.imp.video_crf_combo;
double video_bitrate_m = clt_parameters.imp.video_bitrate_m;
String video_codec_combo = clt_parameters.imp.video_codec_combo.toLowerCase();
boolean use_cuas = clt_parameters.imp.cuas_rotation && clt_parameters.imp.ims_use; // lock_position & ims_use; // needs
int min_num_scenes = use_cuas ? ((int) clt_parameters.imp.cuas_min_series): clt_parameters.imp.min_num_scenes; // abandon series if there are less than this number of scenes in it
......@@ -8862,11 +8863,11 @@ if (debugLevel > -100) return true; // temporarily !
if (this_stereo_width > 0) {// add padding to stereo video
int padded_width= 16* ( (int) Math.round((this_stereo_width + stereo_gap) * stereo_phone_width/stereo_intereye/32));
shellCommand = String.format(
"ffmpeg -y -f concat -safe 0 -i %s -r 60 -vf pad=width=%d:height=0:x=-1:y=-1:color=black,setpts=%f*PTS -b:v 0 -crf %d -c %s %s",
list_to_concat.toString(), padded_width, pts_scale, video_crf_combo, video_codec_combo, video_out.toString());
"ffmpeg -y -f concat -safe 0 -i %s -r 60 -vf pad=width=%d:height=0:x=-1:y=-1:color=black,setpts=%f*PTS -b:v %fM -crf %d -c %s %s",
list_to_concat.toString(), padded_width, pts_scale, video_bitrate_m, video_crf_combo, video_codec_combo, video_out.toString());
} else {
shellCommand = String.format("ffmpeg -y -f concat -safe 0 -i %s -r 60 -vf setpts=%f*PTS -b:v 0 -crf %d -c %s %s",
list_to_concat.toString(), pts_scale, video_crf_combo, video_codec_combo, video_out.toString());
shellCommand = String.format("ffmpeg -y -f concat -safe 0 -i %s -r 60 -vf setpts=%f*PTS -b:v %fM -crf %d -c %s %s",
list_to_concat.toString(), pts_scale, video_bitrate_m, video_crf_combo, video_codec_combo, video_out.toString());
}
Process p = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment