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);
}
When i use only images the code is correctly. But when I use all the code this happens:
[NULL @ 00000000006abe60] Unable to find a suitable output format for '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' 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: Invalid argument
If, as it seems, a space is inserted after each argument in the string, then that explains the error. You haven't enclosed the entire filter_complex in quotes, so a space is inserted between the overlay and drawtext. To FFmpeg, it looks like you terminated the filter_complex with the overlay and hence the drawtext string represents the output.
So either provide the entire filter_complex argument in one string including upto [out]
with no whitespace in between OR add a opening double quote before [0:v]
and closing quote after [out]
. You probably have to escape those quotes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.