我在开发录像机应用程序。现在,我能够记录和保存视频,并成功地将视频转换为URI。
但我需要实现这样的特性:
在视频的某个角落,我需要添加一些水印/文本。例如,我录制了一个视频,我需要添加水标记到视频(任何角落)。例如,我想添加abc.com,比如dubsmash应用程序。
在dubsmash应用程序中录制了一个水渍,对不对?
发布于 2017-08-28 08:03:02
下面是我在视频中添加图像的方法,我在这里将图像路径作为参数传递,首先初始化我的ffmpeg,然后在后台线程中执行命令,将视频转换为在defined和command处定义图像的位置
private void doReplaceTheFrame(String image) {
String[] complexCommand;
int frameCount = (int) (timeInsec * 30);
int startTimeFrame = frameCount - 5;
File f = new File("/storage/emulated/0");
String rootPath = f.getPath();
complexCommand =
new String[]{"-y", "-i", VideoPath1, "-i", image, "-filter_complex",
"[0:v][1:v]overlay=" + xPosition + ":" + yPosition + 10 +
":enable='between" + "(t," + 0 + "," + endTimeOfVideo + ")"
+ "'[out]", "-map", "[out]", rootPath + "/outputFrame.mp4"};
FFmpeg ffmpeg = FFmpeg.getInstance(this);
try {
//Load the binary
ffmpeg.loadBinary(new LoadBinaryResponseHandler() {
@Override
public void onFailure() {
}
@Override
public void onStart() {
}
@Override
public void onSuccess() {
}
@Override
public void onFinish() {
}
});
} catch (FFmpegNotSupportedException e) {
// Handle if FFmpeg is not supported by device
Toast.makeText(getApplicationContext(), "Not Supported by Device",
Toast.LENGTH_LONG).show();
}
try {
final String finalRootPath = rootPath;
ffmpeg.execute(complexCommand, new FFmpegExecuteResponseHandler() {
@Override
public void onSuccess(String message) {
Log.d("Success", message);
Toast.makeText(getApplicationContext(), "Successful" + finalRootPath
.toString(),
Toast.LENGTH_LONG).show();
Uri path = Uri.parse(finalRootPath + "/outputFrame.mp4");
playVideo(path.toString());
}
@Override
public void onStart() {
Log.d("Start", "merge started");
}
@Override
public void onProgress(String message) {
Log.d("progress", message);
pd.show();
}
@Override
public void onFailure(String message) {
Log.d("failure", message);
pd.dismiss();
}
@Override
public void onFinish() {
Log.d("finish", "merge finish");
pd.dismiss();
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
e.printStackTrace();
}
}https://stackoverflow.com/questions/45913512
复制相似问题