gpt4 book ai didi

安卓 ffmpeg : Use image for Watermark from drawable or assets folder

转载 作者:行者123 更新时间:2023-11-29 00:52:39 25 4
gpt4 key购买 nike

如何在 Android 中使用 drawable 文件夹或 assets 文件夹中的图像作为水印。

我找到了许多带有命令的示例,但所有示例都使用内部存储的静态图像路径。

我已经完成了以下代码来制作带水印的视频。

    try {
FFmpeg ffmpeg = FFmpeg.getInstance(mContext);
// to execute "ffmpeg -version" command you just need to pass "-version"

String mSelectedPath = PathUtils.getPathFromUri(mContext, selectedUri);
String mFileName = PathUtils.getFileName(mSelectedPath);
final String mDestinationPath = "/storage/emulated/0/" + mFileName;

String[] array = new String[]{"-i", mSelectedPath , "-i", "/storage/emulated/0/logo.png", "-filter_complex", "[0:v][1:v]overlay=main_w-overlay_w-10:10", "-codec:a", "copy", mDestinationPath};

ffmpeg.execute(array, new ExecuteBinaryResponseHandler() {

@Override
public void onStart() {
Log.d(TAG, "onStart: ");
Toast.makeText(mContext, "Preparing video...", Toast.LENGTH_SHORT).show();
}

@Override
public void onProgress(String message) {
Log.d(TAG, "onProgress: " + message);
Toast.makeText(mContext, "Processing for compression...", Toast.LENGTH_SHORT).show();
}

@Override
public void onFailure(String message) {
Log.d(TAG, "onFailure: " + message);
Toast.makeText(mContext, "Failed to upload, Try Again.", Toast.LENGTH_SHORT).show();
}

@Override
public void onSuccess(String message) {
Log.d(TAG, "onSuccess: " + message);
Toast.makeText(mContext, "Uploading started", Toast.LENGTH_SHORT).show();
mFinalUploadUri = PathUtils.getUriFromPath(mContext, new File(mDestinationPath));
uploadVideo();
}

@Override
public void onFinish() {
Log.d(TAG, "onFinish: ");

}
});
} catch (FFmpegCommandAlreadyRunningException e) {
// Handle if FFmpeg is already running
e.printStackTrace();
}

有人知道如何使用可绘制或 Assets 文件夹中的图像作为水印吗?谁能帮忙?

最佳答案

FFMpeg 不是 Android 环境。 Drawable 和 Assets Directory 仅用于 Android 环境,因此如果您希望将图像添加为水印,您应该只选择文件存储路径

关于安卓 ffmpeg : Use image for Watermark from drawable or assets folder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57833398/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com