FFmpeg 只显示输入文本中的数字(没有字符,只有数字)错误=13,权限被拒绝
The FFmpeg just show the number form the input text (no characters , just numbers) error=13, Permission denied
我试图使用 FFmpeg 创建 gif 格式的视频和音频,在 Android 10 上,不起作用
该代码在 android 9 及以下版本上运行良好,而在 10 及以上版本上运行不正常
Cmd,正如我提到的,它在 android 9 及以下
上工作得很好
String[] cmd = new String[24];
cmd[0] = "-i";
cmd[1] = audio.getPath();
cmd[2] = "-ignore_loop";
cmd[3] = "0";
cmd[4] = "-i";
cmd[5] = image_path;
cmd[6] = "-vf";
cmd[7] = "scale=trunc(iw/2)*2:trunc(ih/2)*2";
cmd[8] = "-filter:v";
cmd[9] = ayat_drawer + qara_draw;
cmd[10] = "-vcodec";
cmd[11] = "libx264";
cmd[12] = "-pix_fmt";
cmd[13] = "yuv420p";
cmd[14] = "-r";
cmd[15] = "25";
cmd[16] = "-preset";
cmd[17] = "ultrafast";
cmd[18] = "-c:a";
cmd[19] = "aac";
cmd[20] = "-b:a";
cmd[21] = "128k";
cmd[22] = "-shortest";
cmd[23] = outputLocation.getPath();
Java代码:
FFmpeg mFFmpeg = FFmpeg.getInstance(context);
try {
mFFmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {
@Override
public void onProgress(String message) {
super.onProgress(message);
callback.onProgress(message);
}
@Override
public void onSuccess(String message) {
super.onSuccess(message);
Utils.refreshGallery(outputLocation.getPath(), context);
callback.onSuccess(outputLocation, "video");
}
@Override
public void onFailure(String message) {
super.onFailure(message);
if (outputLocation.exists()) {
outputLocation.delete();
}
callback.onFailure(new IOException(message));
}
@Override
public void onStart() {
Log.d("TAG", "<ffmpeg>Started command : mFFmpeg " + java.util.Arrays.toString(cmd));
}
@Override
public void onFinish() {
Log.d("TAG", "<ffmpeg>Finished command : mFFmpeg " + java.util.Arrays.toString(cmd));
super.onFinish();
callback.onFinish();
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
Log.e("MAS" , e.getMessage());
e.printStackTrace();
}
我认为是因为 FFmpeg 使用 Asynctask 并且它已被弃用
我找到了使用此代码的解决方案:
https://github.com/umeshlakhani7170/ffmpeg-video-editor-android
我试图使用 FFmpeg 创建 gif 格式的视频和音频,在 Android 10 上,不起作用 该代码在 android 9 及以下版本上运行良好,而在 10 及以上版本上运行不正常 Cmd,正如我提到的,它在 android 9 及以下
上工作得很好 String[] cmd = new String[24];
cmd[0] = "-i";
cmd[1] = audio.getPath();
cmd[2] = "-ignore_loop";
cmd[3] = "0";
cmd[4] = "-i";
cmd[5] = image_path;
cmd[6] = "-vf";
cmd[7] = "scale=trunc(iw/2)*2:trunc(ih/2)*2";
cmd[8] = "-filter:v";
cmd[9] = ayat_drawer + qara_draw;
cmd[10] = "-vcodec";
cmd[11] = "libx264";
cmd[12] = "-pix_fmt";
cmd[13] = "yuv420p";
cmd[14] = "-r";
cmd[15] = "25";
cmd[16] = "-preset";
cmd[17] = "ultrafast";
cmd[18] = "-c:a";
cmd[19] = "aac";
cmd[20] = "-b:a";
cmd[21] = "128k";
cmd[22] = "-shortest";
cmd[23] = outputLocation.getPath();
Java代码:
FFmpeg mFFmpeg = FFmpeg.getInstance(context);
try {
mFFmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {
@Override
public void onProgress(String message) {
super.onProgress(message);
callback.onProgress(message);
}
@Override
public void onSuccess(String message) {
super.onSuccess(message);
Utils.refreshGallery(outputLocation.getPath(), context);
callback.onSuccess(outputLocation, "video");
}
@Override
public void onFailure(String message) {
super.onFailure(message);
if (outputLocation.exists()) {
outputLocation.delete();
}
callback.onFailure(new IOException(message));
}
@Override
public void onStart() {
Log.d("TAG", "<ffmpeg>Started command : mFFmpeg " + java.util.Arrays.toString(cmd));
}
@Override
public void onFinish() {
Log.d("TAG", "<ffmpeg>Finished command : mFFmpeg " + java.util.Arrays.toString(cmd));
super.onFinish();
callback.onFinish();
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
Log.e("MAS" , e.getMessage());
e.printStackTrace();
}
我认为是因为 FFmpeg 使用 Asynctask 并且它已被弃用
我找到了使用此代码的解决方案: https://github.com/umeshlakhani7170/ffmpeg-video-editor-android