vhookPathField.setText(movie.getVhook().toString());
extOptionField.setText(movie.getFfmpegOption().getExtOption());
mainOptionField.setText(movie.getFfmpegOption().getMainOption());
- outputOptionField.setText(movie.getFfmpegOption().getOutOption());
inputOptionField.setText(movie.getFfmpegOption().getInOption());
+ outputOptionField.setText(movie.getFfmpegOption().getOutOption());
+ avfilterOptionField.setText(movie.getFfmpegOption().getAvfilterOption());
FFmpegOptionModel.reload(movie.getOptionFile());
// 変換設定
String main = mainOptionField.getText();
String in = inputOptionField.getText();
String out = outputOptionField.getText();
+ String avfilter = avfilterOptionField.getText();
File optionFile = FFmpegOptionModel.getSelectedFile();
- FfmpegOption opt = new FfmpegOption(ext, main, in, out);
+ FfmpegOption opt = new FfmpegOption(ext, main, in, out, avfilter);
return new MovieSetting(new File(ffmpeg), new File(vhook), optionFile, opt);
}
stopFlagReturn();
sendText("動画の変換を開始");
int code;
- if ((code = converting_video(videoFile, convertedVideoFile, (commentFile != null), commentMiddleFile.getPath(), (tcommFile
+ if ((code = converting_video(videoFile, convertedVideoFile, (commentFile != null), commentMiddleFile.getPath(),
+ (tcommFile
!= null), tcommMiddleFile.getPath(), getFfmpeg().getFfmpegOption())) == 0) {
sendText("変換が正常に終了しました。");
return true;
cmdList.add(opt);
}
}
- if (!getFfmpeg().isVhookDisabled()) {
- if (!addVhookSetting(cmdList, addComment, vhook_path, addTcomment, tcommPath)) {
- return -1;
- }
+
+ List<String> avfilterArgs = getAvfilterOptions(ov, addComment, vhook_path, addTcomment, tcommPath);
+
+ if (!avfilterArgs.isEmpty()) {
+ cmdList.add("-vfilters");
+ final String args = "\"" + StringUtils.join(avfilterArgs, ", ") + "\"";
+ cmdList.add(args);
}
+
cmdList.add(convertedVideoFile.getPath());
System.out.print("arg:");
}
}
- private boolean addVhookSetting(List cmdList, boolean addComment, String vhook_path, boolean addTcomment,
- String tcommPath) {
- try {
- cmdList.add("-vfilters");
- StringBuffer sb = new StringBuffer();
- sb.append("vhext=");
- sb.append(getFfmpeg().getVhook().getPath().replace("\\", "/"));
- if (addComment) {
- sb.append("|");
- sb.append("--data-user:");
- sb.append(URLEncoder.encode(vhook_path.replace("\\", "/"), "Shift_JIS"));
- }
- if (addTcomment) {
- sb.append("|");
- sb.append("--data-owner:");
- sb.append(URLEncoder.encode(tcommPath.replace("\\", "/"), "Shift_JIS"));
- }
- sb.append("|");
- sb.append("--font:");
- sb.append(URLEncoder.encode(
- getFfmpeg().getFont().getPath().replace("\\", "/"), "Shift_JIS"));
+ private List<String> getAvfilterOptions(FfmpegOption ov, boolean addComment, String vhook_path, boolean addTcomment,
+ String tcommPath) throws UnsupportedEncodingException {
+ final List<String> avfilterArgs = new ArrayList<String>();
+ final String avfilterOption = ov.getAvfilterOption();
+ if (StringUtils.isNotBlank(avfilterOption)) {
+ avfilterArgs.add(avfilterOption);
+ }
+ final String vhookArg = (getFfmpeg().isVhookDisabled())
+ ? null : getVhookArg(addComment, vhook_path, addTcomment, tcommPath);
+ if (vhookArg != null) {
+ avfilterArgs.add(vhookArg);
+ }
+ return avfilterArgs;
+ }
+
+ private String getVhookArg(boolean addComment, String vhook_path, boolean addTcomment,
+ String tcommPath) throws UnsupportedEncodingException {
+ StringBuilder sb = new StringBuilder();
+ sb.append("vhext=");
+ sb.append(getFfmpeg().getVhook().getPath().replace("\\", "/"));
+ if (addComment) {
sb.append("|");
- sb.append("--font-index:");
- sb.append(getFfmpeg().getFontIndex());
+ sb.append("--data-user:");
+ sb.append(URLEncoder.encode(vhook_path.replace("\\", "/"), "Shift_JIS"));
+ }
+ if (addTcomment) {
sb.append("|");
- sb.append("--show-user:");
- sb.append(getFfmpeg().getMaxNumOfComment());
+ sb.append("--data-owner:");
+ sb.append(URLEncoder.encode(tcommPath.replace("\\", "/"), "Shift_JIS"));
+ }
+ sb.append("|");
+ sb.append("--font:");
+ sb.append(URLEncoder.encode(
+ getFfmpeg().getFont().getPath().replace("\\", "/"), "Shift_JIS"));
+ sb.append("|");
+ sb.append("--font-index:");
+ sb.append(getFfmpeg().getFontIndex());
+ sb.append("|");
+ sb.append("--show-user:");
+ sb.append(getFfmpeg().getMaxNumOfComment());
+ sb.append("|");
+ sb.append("--shadow:");
+ sb.append(getFfmpeg().getShadowIndex());
+ sb.append("|");
+ if (getFfmpeg().isShowConverting()) {
+ sb.append("--enable-show-video");
sb.append("|");
- sb.append("--shadow:");
- sb.append(getFfmpeg().getShadowIndex());
+ }
+ if (getFfmpeg().isSelfAdjustFontSize()) {
+ sb.append("--enable-fix-font-size");
sb.append("|");
- if (getFfmpeg().isShowConverting()) {
- sb.append("--enable-show-video");
- sb.append("|");
- }
- if (getFfmpeg().isSelfAdjustFontSize()) {
- sb.append("--enable-fix-font-size");
- sb.append("|");
- }
- if (getFfmpeg().isCommentOpaque()) {
- sb.append("--enable-opaque-comment");
- }
- cmdList.add(sb.toString());
- return true;
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- return false;
}
+ if (getFfmpeg().isCommentOpaque()) {
+ sb.append("--enable-opaque-comment");
+ }
+ return sb.toString();
}
private Ffmpeg getFfmpeg() {
public class FfmpegOption {
private final String extOption;
+ private final String mainOption;
private final String inOption;
private final String outOption;
- private final String mainOption;
+ private final String avfilterOption;
public static FfmpegOption load(File file) throws IOException {
Properties prop = new Properties();
prop.loadFromXML(new FileInputStream(file));
String ext = prop.getProperty("EXT");
+ String main = prop.getProperty("MAIN");
String in = prop.getProperty("IN");
String out = prop.getProperty("OUT");
- String main = prop.getProperty("MAIN");
- if (ext == null || in == null || out == null || main == null) {
- throw new IOException("変換オプションファイル書式誤り。");
+ String avfilter = prop.getProperty("AVFILTER");
+
+ if (ext == null || main == null || in == null || out == null || avfilter == null) {
+ throw new IOException("変換オプションファイル書式誤り ext: "
+ + ext + ", main: " + main + ", in: " + in + ", out: " + out + ", avfilter: " + avfilter);
}
- return new FfmpegOption(ext, main, in, out);
+ return new FfmpegOption(ext, main, in, out, avfilter);
}
- public FfmpegOption(String extOption, String mainOption, String inOption, String outOption) {
+ public FfmpegOption(String extOption, String mainOption, String inOption, String outOption, String avfilterOption) {
this.extOption = (extOption.startsWith(".")) ? extOption : "." + extOption;
+ this.mainOption = mainOption;
this.inOption = inOption;
this.outOption = outOption;
- this.mainOption = mainOption;
+ this.avfilterOption = avfilterOption;
}
public String getExtOption() {
return extOption;
}
- public String getInOption() {
- return inOption;
- }
-
public String getMainOption() {
return mainOption;
}
+ public String getInOption() {
+ return inOption;
+ }
+
public String getOutOption() {
return outOption;
}
+
+ public String getAvfilterOption() {
+ return avfilterOption;
+ }
}
* <p>
* タイトル: さきゅばす
* </p>
- *
+ *
* <p>
* 説明: ニコニコ動画の動画をコメントつきで保存
* </p>
- *
+ *
* <p>
* 著作権: Copyright (c) 2007 PSI
* </p>
- *
+ *
* <p>
* 会社名:
* </p>
- *
+ *
* @author 未入力
* @version 1.0
*/
// OutputFileSetting outputFileSetting = p.getOutputFileSetting();
Ffmpeg ffmpeg = p.getFfmpeg();
- FfmpegOption newFfmpegOption = new FfmpegOption(ffmpeg.getFfmpegOption().getExtOption(), "", "", ff);
+ FfmpegOption newFfmpegOption = new FfmpegOption(ffmpeg.getFfmpegOption().getExtOption(), "", "", ff, "");
InputFileSetting newVideoSetting = new InputFileSetting(new SFile(true, new File(video)), false, false);
InputFileSetting newCommentSetting = new InputFileSetting(new SFile(true, new File(comm)), false, false);
InputFileSetting newTcommentSetting = new InputFileSetting(new SFile(true, new File(tcomm)), false, false);
private static final String PROP_CMDLINE_MAIN = "CMD_MAIN";
private static final String PROP_CMDLINE_IN = "CMD_IN";
private static final String PROP_CMDLINE_OUT = "CMD_OUT";
+ private static final String PROP_CMDLINE_AVFILTER = "CMD_AVFILTER";
private final File ffmpeg;
private final File vhook;
private final File optionFile;
prop.setProperty(PROP_CMDLINE_MAIN, getFfmpegOption().getMainOption());
prop.setProperty(PROP_CMDLINE_IN, getFfmpegOption().getInOption());
prop.setProperty(PROP_CMDLINE_OUT, getFfmpegOption().getOutOption());
+ prop.setProperty(PROP_CMDLINE_AVFILTER, getFfmpegOption().getAvfilterOption());
if (getOptionFile() != null) {
prop.setProperty(PROP_OPTION_FILE, getOptionFile().getPath());
} else {
String in = prop.getProperty(PROP_CMDLINE_IN, "");
String out = prop.getProperty(PROP_CMDLINE_OUT,
"-f ipod -g 150 -qcomp 0.7 -qmin 20 -qmax 30 -qdiff 4 -subq 6 -me_range 16 -i_qfactor 0.714286");
- FfmpegOption opt = new FfmpegOption(ext, main, in, out);
+ String avfilter = prop.getProperty(PROP_CMDLINE_AVFILTER, "");
+ FfmpegOption opt = new FfmpegOption(ext, main, in, out, avfilter);
return new MovieSetting(new File(ffmpeg), new File(vhook), optionFile, opt);
}