ffmpeg-cli-wrapper
ffmpeg-cli-wrapper copied to clipboard
Any Success Example Add watermark
Hi,
While browsing the test codes, I tried adding watermark to the video. But I did not get any successful results.
First error;
- java.lang.IllegalStateException: Target size does not support multiple inputs
After delete setTargetSize()
- java.lang.IllegalArgumentException: Target size, or video bitrate must be specified when using two-pass
Anybody have success example to add a watermark on video?
Hi @suhakopan @bramp Here is the code spinet to add watermark on video.
public void addWaterMarkTest() throws IOException{ FFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe);
FFmpegProbeResult in = ffprobe.probe("/home/hariom/Downloads/video.mp4");
FFmpegProbeResult inImage = ffprobe.probe("/home/hariom/Downloads/download.jpeg");
FFmpegBuilder builder = new FFmpegBuilder()
.setInput(in)
.overrideOutputFiles(true)
.addInput(inImage)
.overrideOutputFiles(true)
.addOutput("output1.mp4")
.done().setComplexFilter("overlay=main_w-overlay_w-5:main_h-overlay_h-5");
FFmpegJob job =
executor.createJob(
builder,
new ProgressListener() {
// Using the FFmpegProbeResult determine the duration of the input
final double duration_ns = in.getFormat().duration * TimeUnit.SECONDS.toNanos(1);
@Override
public void progress(Progress progress) {
double percentage = progress.out_time_ns / duration_ns;
// Print out interesting information about the progress
System.out.println(
String.format(
locale,
"[%.0f%%] status:%s frame:%d time:%s fps:%.0f speed:%.2fx",
percentage * 100,
progress.status,
progress.frame,
FFmpegUtils.toTimecode(progress.out_time_ns, TimeUnit.NANOSECONDS),
progress.fps.doubleValue(),
progress.speed));
}
});
job.run();
assertEquals(FFmpegJob.State.FINISHED, job.getState());
}