[英]Getting an error while using JAVE library in an Android project
I'm using an external library called JAVE in my Android project in order to extract the audio from a video file. 我在Android项目中使用了一个名为JAVE的外部库,以便从视频文件中提取音频。
My code: 我的代码:
public void extractAudio() {
File source = new File(Environment.getExternalStorageDirectory().getPath() + "/test.flv");
File target = new File(Environment.getExternalStorageDirectory().getPath() + "/test.mp3");
AudioAttributes audio = new AudioAttributes();
audio.setCodec("libmp3lame");
audio.setBitRate(new Integer(128000));
audio.setChannels(new Integer(2));
audio.setSamplingRate(new Integer(44100));
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("mp3");
attrs.setAudioAttributes(audio);
Encoder encoder = new Encoder();
try {
encoder.encode(source, target, attrs);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InputFormatException e) {
e.printStackTrace();
} catch (EncoderException e) {
e.printStackTrace();
}
}
These are the errors I get: 这些是我得到的错误:
11-09 18:26:49.874: W/System.err(6594): java.io.IOException: Error running exec(). Command: [/bin/chmod, 755, /sdcard/jave-1/ffmpeg] Working Directory: null Environment: null
11-09 18:26:49.874: W/System.err(6594): at java.lang.ProcessManager.exec(ProcessManager.java:211)
11-09 18:26:49.874: W/System.err(6594): at java.lang.Runtime.exec(Runtime.java:168)
11-09 18:26:49.884: W/System.err(6594): at java.lang.Runtime.exec(Runtime.java:123)
11-09 18:26:49.884: W/System.err(6594): at it.sauronsoftware.jave.DefaultFFMPEGLocator.<init>(DefaultFFMPEGLocator.java:85)
11-09 18:26:49.884: W/System.err(6594): at it.sauronsoftware.jave.Encoder.<init>(Encoder.java:111)
11-09 18:26:49.884: W/System.err(6594): at com.yt.ringtones.RipActivity.extractAudio(RipActivity.java:236)
11-09 18:26:49.894: W/System.err(6594): at com.yt.ringtones.RipActivity$1$DownloadFromUrl.onPostExecute(RipActivity.java:94)
11-09 18:26:49.894: W/System.err(6594): at com.yt.ringtones.RipActivity$1$DownloadFromUrl.onPostExecute(RipActivity.java:1)
11-09 18:26:49.894: W/System.err(6594): at android.os.AsyncTask.finish(AsyncTask.java:602)
11-09 18:26:49.894: W/System.err(6594): at android.os.AsyncTask.access$600(AsyncTask.java:156)
11-09 18:26:49.986: W/System.err(6594): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:615)
11-09 18:26:49.986: W/System.err(6594): at android.os.Handler.dispatchMessage(Handler.java:99)
11-09 18:26:49.986: W/System.err(6594): at android.os.Looper.loop(Looper.java:137)
11-09 18:26:49.994: W/System.err(6594): at android.app.ActivityThread.main(ActivityThread.java:4424)
11-09 18:26:49.994: W/System.err(6594): at java.lang.reflect.Method.invokeNative(Native Method)
11-09 18:26:49.994: W/System.err(6594): at java.lang.reflect.Method.invoke(Method.java:511)
11-09 18:26:50.014: W/System.err(6594): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
11-09 18:26:50.014: W/System.err(6594): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
11-09 18:26:50.024: W/System.err(6594): at dalvik.system.NativeStart.main(Native Method)
11-09 18:26:50.024: W/System.err(6594): Caused by: java.io.IOException: No such file or directory
11-09 18:26:50.024: W/System.err(6594): at java.lang.ProcessManager.exec(Native Method)
11-09 18:26:50.034: W/System.err(6594): at java.lang.ProcessManager.exec(ProcessManager.java:209)
I'm rather new to Android development and I'm not really sure what's the problem here. 我是Android开发的新手,我不太确定这是什么问题。 I'd appreciate any help.
我将不胜感激。
"exec()" basically executes a command in a system, as if you would run it from a command line. 基本上,“ exec()”在系统中执行命令,就像从命令行运行它一样。 It is trying to run "/sdcard/jave-1/ffmpeg", which is supposed to be an executable file.
它正在尝试运行“ / sdcard / jave-1 / ffmpeg”,该文件应该是可执行文件。 Do you have this executable on your device?
您的设备上是否有此可执行文件? If not, this will not work.
如果没有,这将不起作用。
This errors happens due to wrong ffmpeg file permissions. 由于错误的ffmpeg文件权限而发生此错误。 Here is my answer in similar thread: Using sauronsoftware's Jave in phonegap Android project
这是我在类似线程中的答案: 在phonegap Android项目中使用sauronsoftware的Jave
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.