String[] code = new String[]{"ffmpeg", "-i","D:/ffmpeg/20170201_164127.mp4",
"-i","D:/ffmpeg/cc.png", "-filter_complex",
"[0:v][1:v]overlay=main_w-overlay_w-5:main_h-overlay_h-5",
"drawtext=fontfile=/ffmpeg/Arial.ttf:text='TESTING'fontcolor=white@1.0:fontsize=70:x=10:y=H-th-10:box=1:boxcolor=black@0.5:boxborderw=5:x=10:y=H-th-10",
"[out]","-map", "[out]", "-map", "2:0",
"-acodec","mp3", "D:/ffmpeg/test7.mp4"};
Process processDuration = new ProcessBuilder(code).redirectErrorStream(true).start();
StringBuilder strBuild = new StringBuilder();
try (BufferedReader processOutputReader = new BufferedReader(new InputStreamReader(processDuration.getInputStream(), Charset.defaultCharset()));) {
String line;
while ((line = processOutputReader.readLine()) != null) {
strBuild.append(line + System.lineSeparator());
}
processDuration.waitFor();
}
String outputJson = strBuild.toString().trim();
System.out.println(outputJson);
}
当我只使用图像时,代码是正确的。但是当我使用所有代码时会发生这种情况:
[NULL @ 00000000006abe60]无法找到合适的输出格式 “DrawText的= fontfile = / ffmpeg的/ ARIAL.TTF:text='TESTING'fontcolor=white@1.0:字号= 70:X = 10:Y = H-TH-10:盒= 1:boxcolor=black@0.5:boxborderw = 5:X = 10:Y = H-TH-10' DrawText的= fontfile = / ffmpeg的/ ARIAL.TTF:text='TESTING'fontcolor=white@1.0:字号= 70:X = 10:Y = H-TH-10:盒= 1:boxcolor=black@0.5:boxborderw = 5:X = 10:Y = H-TH-10: 参数无效
答案 0 :(得分:0)
如果看起来像是在字符串中的每个参数之后插入一个空格,那么这就解释了错误。您没有将整个filter_complex括在引号中,因此在overlay和drawtext之间插入了一个空格。对于FFmpeg,看起来你用overlay覆盖了filter_complex,因此drawtext字符串代表输出。
所以要么在一个字符串中提供整个filter_complex参数,包括最多[out]
,中间没有空格,或者在[0:v]
之前添加一个开头双引号,在[out]
之后结束引用。你可能不得不逃避这些引用。