gpt4 book ai didi

android - 编码器 'aac' 在处理视频以减慢速度时未启用异常

转载 作者:行者123 更新时间:2023-12-04 23:27:38 28 4
gpt4 key购买 nike

在使用 FFMPEG android java 库时发生以下异常的视频播放速度(使视频变慢)。

[aac @ 0x416c26f0] The encoder 'aac' is experimental but experimental codecs are not enabled, add '-strict -2' if you want to use it.

最佳答案

这是一个更改播放速度的命令

 VideoIn = getInternalDirectoryPath() + "/Download/input.mp4";
VideoOut = getInternalDirectoryPath() + "/Download/output.mp4";
cmd = "-i "+VideoIn+" -vf setpts=2*PTS -strict -2 "+VideoOut;

在命令中添加 -strict 避免编码器“aac”不启用异常。您可以按照此链接实现 ffmpeg 视频命令。

这是完整的示例代码
   public class TestFFMpegActivity {
private static String cmd,
private static FFmpeg ffmpeg;
private static Context mContext;


public static String getInternalDirectoryPath() {
return Environment.getExternalStorageDirectory().getAbsolutePath();
}

public static void initiateFFmpeg(Context context, String path) {
mContext = context;
ffmpeg = FFmpeg.getInstance(context);
VideoIn = getInternalDirectoryPath() + "/Download/input.mp4";
VideoOut = getInternalDirectoryPath() + "/Download/output.mp4";
cmd = "-i "+VideoIn+" -vf setpts=2*PTS -strict -2 "+VideoOut;
try {
ffmpeg.loadBinary(new LoadBinaryResponseHandler() {

@Override
public void onStart() {
}

@Override
public void onFailure() {
}

@Override
public void onSuccess() {
}

@Override
public void onFinish() {
processVideo();
}
});
} catch (FFmpegNotSupportedException e) {
// Handle if FFmpeg is not supported by device
}
}
private static void processVideo(){
try {
ffmpeg.execute(cmd ,
new ExecuteBinaryResponseHandler() {

@Override
public void onStart() {
//for logcat
Log.w(null,"processing started");
}

@Override
public void onProgress(String message) {
//for logcat
Log.w(null, "onProgress");
}

@Override
public void onFailure(String message) {
Log.w(null, message.toString());
}

@Override
public void onSuccess(String message) {
Log.w(null, message.toString());
}

@Override
public void onFinish() {

}
});
} catch (FFmpegCommandAlreadyRunningException e) {
Toast.makeText(mContext, "Video processing failed due to exception", Toast.LENGTH_LONG).show();

// Handle if FFmpeg is already running
e.printStackTrace();
Log.w(null, e.toString());
}
}
}

关于android - 编码器 'aac' 在处理视频以减慢速度时未启用异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37559436/

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