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'[email protected]:fontsize=70:x=10:y=H-th-10:box=1:[email protected]: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'[email protected]:fontsize=70:x=10:y=H-th-10:box=1:[email protected]:boxborderw=5:x=10:y=H-th-10' drawtext=fontfile=/ffmpeg/Arial.ttf:text='TESTING'[email protected]:fontsize=70:x=10:y=H-th-10:box=1:[email protected]:boxborderw=5:x=10:y=H-th-10: Invalid argument
ffmpegthat the drawtext filter is the output file. I'm not a Java user, but it's likely a quoting, comma, and/or linebreak issue. Showing the actualffmpegcommand the code produces will show where the issue is. Also, use aac instead of mp3 for MP4: some mainstream, crappy players have trouble decoding that combination. - llogan