bramp / ffmpeg-cli-wrapper

Java wrapper around the FFmpeg command line tool
BSD 2-Clause "Simplified" License
1.73k stars 413 forks source link

How can I add any objects (as text or image) to video with this library? #258

Closed NikitaFilipchuk closed 8 months ago

NikitaFilipchuk commented 2 years ago

I need to add text on video in random time. Something like this example (click)

Can I do something like this with your library?

Euklios commented 8 months ago

This is possible by setting the video filter.

new FFmpegBuilder()
    .addInput("input.mp4")
    .addOutput("output.mp4")
    .setVideoFilter("drawtext=\"fontfile=/path/to/font.ttf: text='Stack Overflow': fontcolor=white: fontsize=24: box=1: boxcolor=black@0.5: boxborderw=5: x=(w-text_w)/2: y=(h-text_h)/2\"")
    .setAudioCodec("copy")
    .done()
    .build();