WaterMarkHelper.java
import android.content.Context;
import android.util.Log;
import com.netcompss.ffmpeg4android.CommandValidationException;
import com.netcompss.loader.LoadJNI;
public class WaterMarkHelper {
private String videoPath;
private String waterMarkPath;
private String overlayX;
private String overlayY;
private String videoOutputPath;
private String videoOutputWidth;
private String videoOutputHeight;
private String videoOutputFps;
private String imgBiteRate;
private String voiceBiteRate;
private String voiceChannelAmount;
private String voiceSampleFrequency;
private String videoOutputSize;
private String waterMarkSettings;
private String[] complexCommand;
WaterMarkHelper(String inputVideoPath,String inputWaterMarkPath,String outputVideoPath,String waterMarkX,String waterMarkY){
videoPath = inputVideoPath;
waterMarkPath = inputWaterMarkPath;
videoOutputPath = outputVideoPath;
overlayX = waterMarkX;
overlayY = waterMarkY;
videoOutputWidth = "";
videoOutputHeight = "";
videoOutputFps = "";
imgBiteRate = "";
voiceBiteRate = "";
voiceChannelAmount = "";
voiceSampleFrequency = "";
videoOutputSize = videoOutputWidth+"x"+videoOutputHeight;
waterMarkSettings = "movie="+waterMarkPath+" [watermark]; [in][watermark] overlay="
+overlayX+":"+overlayY+" [out]";
complexCommand = new String[]{"ffmpeg", "-y", "-i", videoPath, "-strict", "experimental",
"-vf", waterMarkSettings, "-vcodec", "mpeg4", videoOutputPath};
}
public void addVideoWaterMark(Context context) throws CommandValidationException {
Log.d("WaterMarkHelper","starting addVideoWaterMark");
long startTime = System.currentTimeMillis();
LoadJNI vk = new LoadJNI();
String workFolder = context.getApplicationContext().getFilesDir() + "/";
vk.run(complexCommand,workFolder,context.getApplicationContext());
Log.d("WaterMarkHelper","finish addVideoWaterMark, took "+
(System.currentTimeMillis()-startTime)/1000+"seconds.");
}
}