gpt4 book ai didi

android - 如何在android中使用带有输入和输出文件路径的ffmpeg命令?

转载 作者:行者123 更新时间:2023-12-04 22:50:48 26 4
gpt4 key购买 nike

我想在 android 应用程序中使用 ffmpeg 命令。我正在使用这个库从 ffmpeg 开始。

http://writingminds.github.io/ffmpeg-android-java/

我开发了一个演示应用程序并运行命令

ffmpeg 版本

这个命令也给出了准确的输出。但是当我给出任何带有名称的文件路径时,我的命令总是失败,我正在使用:

            String cmd[] = new String[]{"ffmpeg", "-i", "/storage/emulated/0/Videos/dheere.mp4", "-c:v", "libx264", "/storage/emulated/0/Videos/dheere2.3gp"};
execute(cmd);




private void execute(String cmd[]) {


try {
// to execute "ffmpeg -version" command you just need to pass "-version"
FFMpegApp.getFfmpeg().execute(cmd, new ExecuteBinaryResponseHandler() {

@Override
public void onStart() {
Log.e("gc", "Command Started");
}

@Override
public void onProgress(String message) {
Log.e("gc", "onProgress" + message);
}

@Override
public void onFailure(String message) {
Log.e("gc", "onFailure command" + message);
}

@Override
public void onSuccess(String message) {
Log.e("gc", "onSuccess command" + message);
}


@Override
public void onFinish() {
Log.e("gc", "onFinish command");
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
// Handle if FFmpeg is already running
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}

请给我任何建议如何在android中使用命令?
提前致谢。

最佳答案

private void execute() {
String[] cmd = {"ffmpeg -i input_file_path.mp4 -ss 00:00:00.000 -pix_fmt rgb24 -r 10 -s 320x240 -t 00:00:10.000 output_file_path.gif"}

try {
// to execute "ffmpeg -version" command you just need to pass "-version"
FFMpegApp.getFfmpeg().execute(cmd, new ExecuteBinaryResponseHandler() {

@Override
public void onStart() {
Log.e("gc", "Command Started");
}

@Override
public void onProgress(String message) {
Log.e("gc", "onProgress" + message);
}

@Override
public void onFailure(String message) {
Log.e("gc", "onFailure command" + message);
// this will fail in case of wrong input or output path.
}

@Override
public void onSuccess(String message) {
Log.e("gc", "onSuccess command" + message);
}


@Override
public void onFinish() {
Log.e("gc", "onFinish command");
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
// Handle if FFmpeg is already running
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}

关于android - 如何在android中使用带有输入和输出文件路径的ffmpeg命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37482566/

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