gpt4 book ai didi

java - 空对象引用上的 FFmpeg.execute.FFmpegExecuteResponseHandler

转载 作者:行者123 更新时间:2023-11-29 19:53:20 25 4
gpt4 key购买 nike

我的代码:

submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
execFFmpegBinary( " -i" + newFile.getAbsolutePath() + " -codec:v libx264 -profile:v high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k -vf scale=-1:480 -threads 0 -pass 2 -codec:a libfdk_aac -b:a 128k -f mp4 " + dest1.getAbsolutePath());

}
});


public void execFFmpegBinary(final String command) {
try {
Log.d("path....",command);
ffmpeg.execute( command, new ExecuteBinaryResponseHandler() {
@Override
public void onFailure(String s) {
Log.d(TAG, "FAILED with output : " + s);
}

@Override
public void onSuccess(String s) {
Log.d(TAG, "SUCCESS with output : "+s);
}

@Override
public void onProgress(String s) {
Log.d(TAG, "Started command : ffmpeg "+command);
Log.d(TAG, "progress : " + s);
}

@Override
public void onStart() {
Log.d(TAG, "Started command : ffmpeg " + command);
progressDialog.setMessage("Processing...");
progressDialog.show();
}

@Override
public void onFinish() {
Log.d(TAG, "Finished command : ffmpeg " + command);
progressDialog.dismiss();
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
// do nothing for now
}
}

显示这个错误:

FATAL EXCEPTION: main
Process: com.example.mypc.videocut, PID: 26910
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.github.hiteshsondhi88.libffmpeg.FFmpeg.execute(java.lang.String, com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteResponseHandler)' on a null object reference

最佳答案

ffmpeg 当前未实例化

你必须先打电话:

ffmpeg = FFmpeg.getInstance(this);

并尝试加载库:

try {
ffmpeg.loadBinary(new LoadBinaryResponseHandler() {
@Override
public void onFailure() {
Log.e(TAG,"");
}
});
} catch (FFmpegNotSupportedException e) {
Log.e(TAG,"");
}

所以之后你可以使用execute方法

关于java - 空对象引用上的 FFmpeg.execute.FFmpegExecuteResponseHandler,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36933240/

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