[FFmpeg-user] Combining clipping and add an overlay

Darrin Smith darrinps at gmail.com
Fri Aug 16 04:02:13 EEST 2019

I have a master video I wish to take a clip out of and on that clip place
an overlay (mostly transparent png file).

Does this need to be a two step process, first creating the clip, then
reading it in and adding the overlay, or can it be combined into one step
to save time?

To create the clip I have successfully used this command (in Kotlin):
val cmd = "-ss $start -t $duration -accurate_seek -i $inputFile -codec copy
-avoid_negative_ts 1 $outputFile"

val command = cmd.split(" ".toRegex()).dropLastWhile { it.isEmpty()

FFmpeg.getInstance(context).execute(command, object :
ExecuteBinaryResponseHandler() {...}

For the overlay, I know I need to do something like this:

val cmd2 = "-y -i $sourceMp4 -i overlayImage.png -filter_complex
\"[1]format=bgra,colorchannelmixer=aa=1,rotate=0:c=black at 0:ow=rotw(0):oh=roth(0)[overlayImage];[0][overlayImage]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2\"

Can those two be commands be combined?


More information about the ffmpeg-user mailing list